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

Elasticsearch嵌套聚合
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"
               }
             }
         }
      }
   }
}'
Elasticsearch嵌套聚合

执行命令如下:

Elasticsearch嵌套聚合

Elasticsearch嵌套聚合

本文转自博客园xingoo的博客,原文链接:Elasticsearch嵌套聚合,如需转载请自行联系原博主。

相关文章:

  • 2021-10-18
  • 2021-10-10
  • 2021-04-13
  • 2022-01-04
  • 2021-07-05
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案