es聚合后比较结果显示

GET /gunspoc/_search
{
  "query": {
    "match_all": {}
  },
  "aggregations": {
    "aggrs": {
      "terms": {
        "field": "age"
      },
      "aggregations": {
        "avgs": {
          "avg": {
            "field": "age"
          }
        },
        "sums":{
          "sum": {
            "field": "age"
          }
        },
        
        "having":{
          "bucket_selector": {
            "buckets_path": {
              "aggrs": "avgs",
              "sums":"sums"
            },
            "script": {
              "source": "params.aggrs > 21 && params.sums >=2 "
            }
          }
        }
      }
    }
  }
}

 

posted @ 2021-11-09 17:36  动力起点  阅读(193)  评论(0编辑  收藏  举报