ES聚合实例

在es中需要根据app_categor进行聚合,JSON查询语句如下:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "flag_color": "3"
          }
        },
        {
          "term": {
            "atype": "0"
          }
        },
        {
          "term": {
            "flag_off": "0"
          }
        }
      ]
    }
  },
  "explain": true,
  "aggs": {
    "appCategory": {
      "terms": {           //聚合字段为字母
        "field": "app_category",  //聚合字段
        "order": [          //按聚合字段字母进行排序
          {
            "_term": "asc"     
          }
        ],
        "size": 50                 //聚合显示结果数量(默认10条)
      }
    }
  }
}

 

posted @ 2017-01-09 15:45  0xcafedaddy  阅读(248)  评论(0编辑  收藏  举报