关系型数据库和Elasticsearch 对比
数据库 | 表 | |
关系型数据库 | database | table |
Elasticsearch | index | type |
http://localhost:9200/ruge_blog/
http://localhost:9200/ruge_blog/ruge_user/1/
{
"title":"java后端研发",
"salary_min":20000,
"Company":{
"name":"百度",
"address":"北京"
}
}
造了三条数据
http://localhost:9200/ruge_blog/ruge_user/_search/ POST
{
"query":{
"term":{
"title":"java"
}
}
}
返回值
{
"took":146,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":3,
"max_score":0.2876821,
"hits":[
{
"_index":"ruge_blog",
"_type":"ruge_user",
"_id":"2",
"_score":0.2876821,
"_source":{
"title":"java后端研发",
"salary_min":40000,
"Company":{
"name":"阿里",
"address":"深圳"
}
}
},
{
"_index":"ruge_blog",
"_type":"ruge_user",
"_id":"1",
"_score":0.2876821,
"_source":{
"title":"java后端研发",
"salary_min":30000,
"Company":{
"name":"百度",
"address":"北京"
}
}
},
{
"_index":"ruge_blog",
"_type":"ruge_user",
"_id":"3",
"_score":0.2876821,
"_source":{
"title":"java后端研发",
"salary_min":30000,
"Company":{
"name":"腾讯",
"address":"深圳"
}
}
}
]
}
}
http://localhost:9200/ruge_blog/ruge_user/_search/ POST
{
"query":{
"query_string":{
"default_field":"salary_min",
"query":"30000"
}
}
}
返回值
{
"took":53,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":2,
"max_score":1,
"hits":[
{
"_index":"ruge_blog",
"_type":"ruge_user",
"_id":"1",
"_score":1,
"_source":{
"title":"java后端研发",
"salary_min":30000,
"Company":{
"name":"百度",
"address":"北京"
}
}
},
{
"_index":"ruge_blog",
"_type":"ruge_user",
"_id":"3",
"_score":1,
"_source":{
"title":"java后端研发",
"salary_min":30000,
"Company":{
"name":"腾讯",
"address":"深圳"
}
}
}
]
}
}