jamh

前言

在使用ES搜索的时候,或多或少都会面临查询数据总量的情况,下面介绍三种查询数据总量的方式。

其中,方案二解决了当结果数据总量超过1w时,由于ES默认设置(max_result_window:10000,出于性能问题考虑,用户也不想放开这个限制),只能返回命中数等于1w的问题。

方案一

查询全部索引下的文档总数:

GET /_cat/count

查询某个索引下的文档总数(<target>为索引名):

GET /_cat/count/<target>

官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html

方案二

track_total_hits" 属性设置为 true(<target>为索引名)

GET <target>/_search
{
  "track_total_hits": true,
  // 

相关文章:

  • 2021-05-10
  • 2021-05-02
  • 2021-02-23
  • 2020-06-18
  • 2021-07-05
  • 2019-09-09
  • 2021-02-03
猜你喜欢
  • 2020-03-21
  • 2021-11-21
  • 2018-12-01
  • 2021-07-06
  • 2021-11-05
  • 2021-05-11
  • 2021-10-20
相关资源
相似解决方案