1. 程式人生 > >Elasticsearch分組聚合-查詢

Elasticsearch分組聚合-查詢

1 統計某個欄位下的分組情況

類似如下功能:
select count(*) from mytable group by myfield

curl -XPOST 'localhost:19200/ylchou-0-2015-10-07/_search?pretty' -d '
 {
    "size": 0,
    "aggs": {
      "group_by_state": {
        "terms": {
          "field": "A_logtype"
        }
      }
    }
}'