赞
踩
6.8版本返回的命中文档的数量是精确的,7.2版本不一定是精确的
hits.total
– 命中总数(精确值)
{ "took" : 0, "timed_out" : false, "_shards" : { "total" : 3, "successful" : 3, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 10001, "max_score" : 1.0, "hits" : [ { "_index" : "yth_file_nested_relation", "_type" : "mytype", "_id" : "29f22162c0c56de4f4a6aafc64f46423", "_score" : 1.0, "_source" : { } } ] } }
hits.total
– 搜索命中总数信息
hits.total.value
- 命中总数
hits.total.relation
- 取值eq(等于)/gte(大于等于),表示hits.total.value与实际的搜索命中数量的关系。
如果搜索结果很多,超过一定数量后,通常就不再统计,只是笼统地表示为:搜索结果超过XXXX个。hits.total的准确性由请求参数track_total_hits控制
GET index/_search
{
"track_total_hits":true
}
默认情况下,track_total_hits默认值为10,000,意味着总命中数可以精确地跟踪到10000个文档,如果超过10000,会表示为超过10000个结果,如下所示:
{
"total" : {
"value" : 10000,
"relation" : "gte"
}
}
当track_total_hits为true时,搜索时将精确地跟踪总命中数,如下所示:
{
"total" : {
"value" : 10101,
"relation" : "eq"
}
}
当track_total_hits为false时,不返回命中文档数,如下所示:
{ "took" : 3, "timed_out" : false, "_shards" : { "total" : 3, "successful" : 3, "skipped" : 0, "failed" : 0 }, "hits" : { "max_score" : 1.0, "hits" : [ { "_index" : "yth_file_nested_relation", "_type" : "_doc", "_id" : "8tlgI3MBlFQMKn7AXrSY", "_score" : 1.0, "_source" : { } } ] } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。