ES通过指定条件筛选后,计算平均值

GET applog-xmllog-2021-01-04/_search?pretty
{
    "size": 0,  //加上后可不显示命中(hits)的文档数据
    "query":{
        "bool":{
            "must":[
                {
                    "term":{
                        "class_name.keyword":"ShunFeng"
                    }
                },
                {
                    "term":{
                        "method_name.keyword":"SearchFlights"
                    }
                },
                {
                    "range":{
                      "created_time":{
                        "lte": "now",
                        "gte": "now-30m"
                      }
                    }
                } 
                
            ]
        }
    },
    "aggs": {
    "duration_rate": {
      "avg": {
        "field": "duration"
      }
    }
  }
}
posted @ 2021-01-04 16:05  划破黑夜  阅读(874)  评论(0编辑  收藏  举报