ES对某个字段分组

GET indexName/_search?pretty
{
    "size": 0,  
    "query":{
        "bool":{
            "must":[
                {
                    "term":{
                        "fieldName":"***"
                    }
                }
            ],
            "must_not": [
              {
                "term": {
                  "fieldName": "***"
                }
              }
            ]
        }
    },
    "aggs": {
        "group_by_tags": {
            "terms": { "field": "fieldName.keyword" ,"size": 200}
        }
    }
}

fieldName:替换成相应的字段

posted @ 2021-07-05 08:39  划破黑夜  阅读(1558)  评论(0编辑  收藏  举报