要不要再翻翻文档呢?

什么时候用 track_total_hits =true ,什么时候用count 合适

Elasticsearch | 作者 wright | 发布于2019年12月19日 | 阅读数:5051

列表 分页的时候,需要知道 某一组查询条件下的 总数,什么时候用 track_total_hits =true ,什么时候用count 合适,主要是订单列表场景, 两者性能 有什么差距,有没有 大神 给点建议
已邀请:

Ombres

赞同来自: wright

_count 其实就是_search的一种,只不过设置了固定的两个参数,size=0和track_total_hits=true
 当你要查结果列表的时候,想要同时获取总数,用_search,加上track_total_hits=true
单纯的想知道总数的时候,使用_count 或者  用_search,加上size=0和track_total_hits=true
 
 

要回复问题请先登录注册