使用elasticsearch 6.7时,
GET /indexName/_search
返回索引的确切总数:
"hits" : {
"total" : 1527325,
"max_score" : 1.0,
...}
但在 elasticsearch 7.0 中
GET /indexName/_search
得到:
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
这意味着总数大于10000,那么我如何才能获得7.0中索引的确切总数?
最佳答案
从 ES 7.0.0 开始,您需要使用 track_total_hits
参数:
GET /indexName/_search?track_total_hits=true
您也可以添加 rest_total_hits_as_int
参数,如果您想恢复与 7 之前版本相同的格式(将在 ES 8 中删除的临时参数):
GET /indexName/_search?track_total_hits=true&rest_total_hits_as_int=true
关于elasticsearch - 如何在elasticsearch7中获取索引的项目数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56238141/