本文档为您介绍使用阿里云Elasticsearch(简称ES)服务对文档数据进行统计分析的方法。

通过Kibana控制台访问阿里云ES,执行以下命令对文档数据进行统计分析,详情请参见ES官方的Aggregation文档。
POST /my_index/_search?pretty
{
  "size": 0,
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags"
      }
    }
  }
}
运行成功后,结果如下:
{
  "took" : 19,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 3,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "aggregations" : {
    "group_by_tags" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "ruby",
          "doc_count" : 3
        }
      ]
    }
  }
}