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获取到的多不少。

相关推荐
AI_Claude_code5 分钟前
ZLibrary访问困境方案三:Web代理与轻量级转发服务的搭建与优化
爬虫·python·web安全·搜索引擎·网络安全·web3·httpx
RD_daoyi6 小时前
新手小白独立站运营实操手册:从0到1跑通流量-转化-留存闭环
搜索引擎
老纪的技术唠嗑局7 小时前
告别OpenClaw配置丢失——Mindkeeper内测版邀测
大数据·elasticsearch·搜索引擎
老陈头聊SEO7 小时前
高效整合长尾关键词以提升网站SEO排名的有效策略
其他·搜索引擎·seo优化
key_3_feng7 小时前
揭秘AI的“语言积木“:Token科普之旅
人工智能·搜索引擎·token
Elasticsearch7 小时前
使用 Elasticsearch + Jina embeddings 进行无监督文档聚类
elasticsearch
勇哥的编程江湖9 小时前
flinkcdc streaming 同步数据到es记录过程
大数据·elasticsearch·flink·flinkcdc
曾阿伦9 小时前
Elasticsearch 7.x 常用命令备忘录
大数据·elasticsearch·搜索引擎
斯特凡今天也很帅10 小时前
Elasticsearch数据库专栏(二)DSL语句总结(更新中)
大数据·elasticsearch·搜索引擎
要记得喝水10 小时前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash