【问题标题】:Elastic search document count弹性搜索文档计数
【发布时间】:2016-08-19 19:18:58
【问题描述】:

我有一个运行 2.2 版本的 Elastic 搜索。我已经创建了索引并加载了示例文档。我在其中发现了一些问题。当我给

GET index/type/_count

我得到了正确的答案

{
   "count": 9998,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   }
}

但是当我看到使用http://IP:9200/_cat/indices?v的东西时

health status index pri rep docs.count docs.deleted store.size pri.store.size     
yellow open   index  5   1      79978            0     32.1mb         32.1mb 

其中 docs.count : 79978。这是错误的。

为什么我看到 docs.count 的值错误。准确的文档数是 9998

【问题讨论】:

  • 同一索引中可能有其他类型的文档,请尝试 GET index/_count 确认
  • { "count": 9998, "_shards": { "total": 5, "successful": 5, "failed": 0 } } 我得到相同的 9998。当我给 GET index/_count
  • 您的映射中是否有带有nested 类型的字段?
  • @Val,是的,我有

标签: elasticsearch indexing count


【解决方案1】:

GET index/type/_count 将返回顶级文档计数。

docs.count in _cat/indices 返回所有文档的计数,包括为嵌套字段创建的人工文档。

这就是你看到不同的原因:

  • 前一个计数(即 9998)将告诉您索引中有多少 Elasticsearch 文档,即您已编入索引的数量。
  • 后一个计数(即 79978)将告诉您索引中有多少 Lucene 文档

因此,如果一个 ES 文档包含一个包含 5 个子元素的嵌套字段,您将看到 1 个 ES 文档,但 6 个 Lucene 文档。从计数来看,每个 ES 文档中都有 7 到 8 个嵌套元素。

【讨论】:

  • 这是否记录在任何地方?
  • @youhans 是的 here
猜你喜欢
  • 2015-12-18
  • 2022-08-12
  • 2015-06-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多