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 中国社区官方博客8 小时前
用于 JavaScript 和 TypeScript 的 ES|QL 查询构建器:流式、类型安全的查询构建
大数据·javascript·数据库·elasticsearch·搜索引擎·typescript·全文检索
qcx239 小时前
Warp源码深度解析(六):AI Agent的Context管理——从9种上下文到流水线组装
大数据·人工智能·elasticsearch
黑风风9 小时前
深入学习 ElasticSearch 的搜索(六):搜索语法总结
elasticsearch
Volunteer Technology10 小时前
ES相关度评分算法
大数据·算法·elasticsearch
独隅10 小时前
it+云原生:GitOps实践指南-K8s配置版本管理
git·elasticsearch·云原生
海兰10 小时前
将 Cursor 连接到生产日志:通过 Elastic MCP 服务器
运维·服务器·elasticsearch
Elastic 中国社区官方博客10 小时前
2026 年金融服务可观测性现状:从实施到业务影响
大数据·运维·人工智能·elasticsearch·搜索引擎·金融·自动化
刘佬GEO10 小时前
口腔门诊第一次做 GEO:第一步动作与起步策略拆解
网络·人工智能·搜索引擎·ai·语言模型
啊吧怪不啊吧11 小时前
C++之基于正倒排索引的Boost搜索引擎项目日志+server代码及详解
c++·搜索引擎·项目
Cc不爱吃洋葱11 小时前
RAG最佳实践:用 ElasticSearch 打造AI搜索系统与RAG 应用全流程详解!
人工智能·elasticsearch·大模型·大语言模型·rag·ai工具·大模型应用