_stats与_count返回的弹性搜索文档计数 [英] Elasticsearch document count returned by _stats versus _count

查看:160
本文介绍了_stats与_count返回的弹性搜索文档计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在弹性搜索集群(1.2.1)中获取统计数据。我正在使用指数统计API (_stats端点)获取主文档的总数及其大小。不过,我开始试用 Count API (_count端点),并注意到值不对齐。

I'm trying to get statistics/counts on indices in my elasticsearch cluster (1.2.1). I was using the Indices Stats API (_stats endpoint) to get the total number of primary documents and their size on disk. However, I started experimenting with the Count API (_count endpoint) and noticed that the values do not align.

这些值之间有什么区别?从文档中还不完全清楚,但文档中的线索表明刷新索引时,从重新统计信息返回的值可能会发生变化。这使我想知道这是否是Lucene层的较低级别的值。

What is the difference between these values? It's not entirely clear from the documentation though a clue in the documentation indicates that the value returned from Indicies Stats can change when refreshing the index. This makes me wonder if this is a lower-level value from the Lucene layer.

指数统计API

localhost:9200/my_index/_stats

...snip...

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

...snip...

Count API

Count API

localhost:9200/my_index/_count

{
  "count" : 6854,
  "_shards" : {
    "total" : 40,
    "successful" : 40,
    "failed" : 0
  }
}


推荐答案

其实, docs.count 从索引统计数据返回统计API还包括索引中存在的嵌套文档的计数,因此它将始终大于或等于从Count API返回的计数,该API仅返回顶级文档的计数,即文档那将会退回ma搜索查询

Actually, the docs.count you get back from the Indices stats API also includes the count of nested documents present in the index so it will always be greater or equals than the count you get back from the Count API, which only returns the count of top-level documents, i.e. documents that would be returned from a search query.

所以,根据你发布的数字,看起来你的索引包含的文档的类型是嵌套在映射。听起来不正确?

So, judging by the numbers you posted, it looks like your index contains documents with fields whose type is nested in the mapping. Sounds correct?

这篇关于_stats与_count返回的弹性搜索文档计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆