条件查询
查询 age 等于 25 岁的人
GET /user/docs/_search?q=age:25
GET /user/docs/_search?q=age:25
也可以写其他的条件
GET /user/docs/_search?q=age:<=28
GET /user/docs/_search?q=age:<=28
有数据返回
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "user",
"_type" : "docs",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "王五",
"sex" : 1,
"age" : 25,
"address" : "河北省"
}
}
]
}
}
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "user",
"_type" : "docs",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "王五",
"sex" : 1,
"age" : 25,
"address" : "河北省"
}
}
]
}
}
无数据返回
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}