其他分享
首页 > 其他分享> > ES对某个字段分组

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:替换成相应的字段

标签:term,替换成,fieldName,query,某个,分组,must,ES,size
来源: https://www.cnblogs.com/wugang/p/14970740.html