Elasticsearch嵌套聚合

 Elasticserch在新版本中支持聚合操作,而聚合操作也可以嵌套使用,方法如下:

curl -XGET 10.4.44.19:9200/test/test/_search?pretty -d '
{
   "aggs":{
      "color_type_max":{
         "terms":{ 
            "field": "color"
         },
         "aggs":{
            "max_age": {
               "max": { 
                 "field" : "age"
               }
             }
         }
      },
      "color_type_min":{
         "terms":{ 
            "field": "color"
         },
         "aggs":{
            "min_age": {
               "min": { 
                 "field" : "age"
               }
             }
         }
      }
   }
}'

执行命令如下:

posted @ 2015-08-06 17:29  xingoo  阅读(4392)  评论(1编辑  收藏  举报