_count在弹性搜索中的作用是什么?我知道我可以使用端点_search在弹性搜索中获取数据。
谢谢
答案 0 :(得分:1)
_count
API的目的仅仅是获得给定查询的匹配数。
它接受与_search
API相同的输入,但不返回任何匹配,只是返回匹配项。
带有size=0
的Search API将返回以下内容:
POST index/_search?size=0
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 10931164,
"max_score" : 0.0,
"hits" : [ ]
}
}
Count API将返回以下内容:
POST index/_count
{
"count" : 10931164,
"_shards" : {
"total" : 3,
"successful" : 3,
"skipped" : 0,
"failed" : 0
}
}