我正尝试在 Total_volume
的基础上,借助bucket_sort对以下聚合的结果存储桶进行排序汇总:
"aggs": {
"Originrampname": {
"terms": {
"field": "OriginRampName.keyword"
},
"aggs": {
"Destinationrampname": {
"terms": {
"field": "DestinationRampName.keyword"
},
"aggs": {
"Total_volume": {
"sum": {
"script": {
"source": "doc['BilledCount'].value+doc['MovedCount'].value+doc['InGatedCount'].value",
"lang": "painless"
}
}
},
"sorting": {
"bucket_sort": {
"sort": [
{
"Total_volume": {
"order": "desc"
}
}
]
}
}
}
}
}
}
}
结果:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 6,
"max_score": 0,
"hits": []
},
"aggregations": {
"Originrampname": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Albany South",
"doc_count": 3,
"Destinationrampname": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Chicago South",
"doc_count": 3,
"Total_volume": {
"value": 561
}
}
]
}
},
{
"key": "Albany Central",
"doc_count": 2,
"Destinationrampname": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Chicago South",
"doc_count": 2,
"Total_volume": {
"value": 1223
}
}
]
}
},
{
"key": "Albany You",
"doc_count": 1,
"Destinationrampname": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Chicago South",
"doc_count": 1,
"Total_volume": {
"value": 886
}
}
]
}
}
]
}
}
}
正如您在这里可以清楚地看到的那样,这些存储桶不是按照我定义的标准进行排序的,即Total Volume(但它们是基于doc_count进行排序的)。您能指出我这里的问题还是我犯的任何错误吗?
谢谢