根据某一fieldA进行分组,然后按每组中另一fieldB的总和,进行排序,取前5

{
    "track_total_hits": "true",
    "query": {
        "bool": {
            "must": []
        }
    },
    "size": 0,
    "aggs": {
        "nums": {
            "aggs": {
                "count": {
                    "sum": {
                        "field": "B.trigger_nums"
                    }
                }
            },
            "terms": {
                "field": "A.keyword",
                "size": 5,
                "order": {
                    "count": "desc"
                }
            }
        }
    }
}

你可能感兴趣的:(根据某一fieldA进行分组,然后按每组中另一fieldB的总和,进行排序,取前5)