我希望通过dsl查询得到结果,返回按类别过滤并按客户名分组,然后在该用户的每个类别中重新调整总数。这里我尝试了:
但我希望在此结果中重新分配每个类别,它应该是:
"buckets": [
{
"key": "50",
"doc_count": 87,
"respsize": 23213
},
{
"key": "49",
"doc_count": 25,
"respsize": 23213
}
答案 0 :(得分:0)
试试这个agg; - )
"aggs": {
"by_clients": {
"terms": {
"field": "clientname"
},
"aggs": {
"by_categories": {
"terms": {
"field": "category"
},
"aggs": {
"total_respsize": {
"sum": {"field": "respsize"}
}
}
}
}
}
}