美文网首页
ES(Aggregations聚合)基本使用

ES(Aggregations聚合)基本使用

作者: 凡哥爱丽姐 | 来源:发表于2023-02-11 20:06 被阅读0次
搜索address中包含mill的所有年龄分布和平均年龄
##搜索address中包含mill的所有年龄分布和平均年龄
GET bank/_search
{
  "query":{
   "match": {
     "address":"mill"
   }
  },
  "aggs": {
    "ageAgg": {
      "terms": {
        "field": "age",
        "size": 10
      }
    },
    "ageAvg":{  
      "avg": {    
        "field": "age"
      }
    }
  }
}
按年龄聚合,并且算出这些不同年龄分布的平均薪资
##按年龄聚合,并且算出这些不同年龄分布的平均薪资
GET bank/_search
{
   "query": {
     "match_all": {}
   },
   "aggs": {
     "ageAgg": {
       "terms": {
         "field": "age",
         "size": 100
       },
       "aggs": {
         "balanceAvg": {
           "avg": {
             "field": "balance"
           }
         }
       }
       
     }
   }
}

相关文章

网友评论

      本文标题:ES(Aggregations聚合)基本使用

      本文链接:https://www.haomeiwen.com/subject/kdjljrtx.html