1.count
查询name字段中包含Mike的文档数。
POST /people/_count
{
"query": {
"bool": {
"filter": [{
"match": {
"name": "Mike"
}
}]
}
}
}
{
"count" : 3,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
}
}
2.source
通过_source,只显示文档的name和country字段。
POST /people/_search
{
"_source": ["name", "country"],
"query": {
"match": {
"name": "Mike"
}
}
}
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 0.105360515,
"hits" : [
{
"_index" : "people",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.105360515,
"_source" : {
"country" : "China",
"name" : "Mike Steven"
}
},
{
"_index" : "people",
"_type" : "_doc",
"_id" : "mom6gXsBEsHOdz1YRcov",
"_score" : 0.105360515,
"_source" : {
"country" : "China",
"name" : "Mike Sherry"
}
},
{
"_index" : "people",
"_type" : "_doc",
"_id" : "nonCgXsBEsHOdz1YDcoP",
"_score" : 0.105360515,
"_source" : {
"country" : "Englend",
"name" : "Mike Owen"
}
}
]
}
}