_stats与_count返回的弹性搜索文档计数

Ale*_*yak 9 database rest nosql elasticsearch

我正在尝试获取弹性搜索集群中的索引的统计数据/计数(1.2.1).我使用Indices Stats API(_stats端点)来获取主文档的总数及其在磁盘上的大小.但是,我开始尝试使用Count API(_count端点)并注意到值不对齐.

这些值有什么区别?虽然文档中的线索表明刷新索引时Indicies Stats返回的值可能会发生变化,但文档中并未完全清楚.这让我想知道这是否是Lucene层的低级值.

指数统计API

localhost:9200/my_index/_stats

...snip...

"_all" : {
  "primaries" : {
    "docs" : {
      "count" : 8284,
      "deleted" : 87
    },
  }
}

...snip...
Run Code Online (Sandbox Code Playgroud)

计算API

localhost:9200/my_index/_count

{
  "count" : 6854,
  "_shards" : {
    "total" : 40,
    "successful" : 40,
    "failed" : 0
  }
}
Run Code Online (Sandbox Code Playgroud)

Val*_*Val 19

实际上,docs.count从Indices stats API返回的还包括索引中存在的嵌套文档的数量,因此它总是大于或等于从Count API返回的计数,它只返回顶级计数文档,即将从搜索查询返回的文档.

因此,根据您发布的数字判断,您的索引看起来像包含类型nested在映射中的字段的文档.听起来不错?