Elasticsearch嵌套聚合

时间:2022-04-22
本文章向大家介绍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"
               }
             }
         }
      }
   }
}'

执行命令如下: