ElasticSearch type level stats 怎么做?

新手上路,请多包涵

我使用Elasticsearch1.7.3,根据文档的indices-stats章节,可以进行type level stats。

参数:indexing

Indexing statistics, can be combined with a comma separated list of types to provide document type level stats.

例子:
curl 'localhost:9200/my_index/_stats?clear=true&indexing=true&types=type1,type2'

可是这个例子我试了下返回结构就是跟localhost:9200/my_index/_stats/indexing是一样的,也就是说types参数完全没有起到作用,求问这个api到底怎么用?

另外说下我的需求,看看有没有别的方式可以实现的:

一个index下有99个type,现在想统计每个type下的数据量。

求大神解救!

阅读 2.6k
1 个回答
✓ 已被采纳新手上路,请多包涵

找到答案了。
1) api是没有问题的,可以用,当时我本地的idnexing有问题,所有返回都是0。
不过这个api返回的是索引的状况,并不是我想要的doc统计。

2) 使用aggs

http://elasticsearch:9200/your_index/_search?search_type=count
{
  "aggs": {
    "count_by_type": {
      "terms": {
        "field": "_type"
      }
    }
  }
}

使用aggs统计_type字段即可。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进