elasticsearch _cat/indices docs.count is different than <index>/_count

今天遇到一个问题,kibana中看到文档数与下面语句查询到的不同

bash 复制代码
GET /_cat/count/jiankunking_xxxxx_product_expand_test?v
GET /jiankunking_xxxxx_product_expand_test/_search?track_total_hits=true

语句查询结果

bash 复制代码
epoch      timestamp count
1711433785 06:16:25  508666675

kibana数据

kibana这里看到的数据与GET _cat/indices?v获取到的结果是一样的

语句

bash 复制代码
GET _cat/indices/jiankunking_xxxxx_product_expand_test?v

结果

bash 复制代码
health status index                                  uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   jiankunking_xxxxx_product_expand_test7BbNsDs_RVyOR1Wn4LZoDA   6   0  894203500        88097    336.8gb        336.8gb

那么到底哪个是对的呢?

在GitHub中找到了原因:https://github.com/elastic/elasticsearch/issues/25868

cat api 和 count api 之间存在差异。前者查看的是 Lucene 统计,而后者执行的是查询。Lucene 统计会考虑到已删除的文档和嵌套文档,而这两种情况都隐藏在搜索次数中。

由于jiankunking_xxxxx_product_expand_test中有多个nested属性,所以cat的数量是比count api获取到的多不少。

相关推荐
Elastic 中国社区官方博客10 小时前
Elasticsearch:使用推理端点及语义搜索演示
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elasticsearch19 小时前
在 Elastic Cloud on Kubernetes 部署中的多租户示例架构
elasticsearch
INFINI Labs1 天前
如何使用 INFINI Gateway 对比 ES 索引数据
大数据·elasticsearch·gateway·easysearch
Elasticsearch2 天前
Elasticsearch:使用推理端点及语义搜索演示
elasticsearch
Elasticsearch2 天前
在 Elasticsearch 中改进 Agentic AI 工具的实验
elasticsearch
Elastic 中国社区官方博客2 天前
在 Elasticsearch 中改进 Agentic AI 工具的实验
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
FIN66683 天前
昂瑞微IPO前瞻:技术破局高端射频模组,国产替代第二波浪潮下的硬科技突围
前端·科技·搜索引擎·产品运营·创业创新·制造·射频工程
羽_羊3 天前
Elasticsearch 之分页查询
elasticsearch·scroll·search_after
LaughingZhu3 天前
Product Hunt 每日热榜 | 2025-10-03
人工智能·经验分享·搜索引擎·产品运营
深思慎考4 天前
【新版】Elasticsearch 8.15.2 完整安装流程(Linux国内镜像提速版)
java·linux·c++·elasticsearch·jenkins·框架