Closed
Description
See #83957 (comment) for the reproduction and the description of the issue.
Original bug report:
Elasticsearch Version
6.4.3
Installed Plugins
/
Java Version
bundled
OS Version
linux
Problem Description
using the bucket_sort in a filters aggregation results in no sorting at all
Steps to Reproduce
Example query:
{
"aggs": {
"Category": {
"filters": {
"other_bucket": false,
"other_bucket_key": "No Category",
"filters": {
"165422": {
"term": {
"product.categories.id": 165422
}
},
"171229": {
"term": {
"product.categories.id": 171229
}
},
"165523": {
"term": {
"product.categories.id": 165523
}
},
"165530": {
"term": {
"product.categories.id": 165530
}
}
}
},
"aggs": {
"cancelation_count": {
"sum": {
"script": {
"inline": "if(doc['order_cancellation_id'].value > 0){return 1} return 0;",
"lang": "painless"
}
}
},
"sort_cancelation_count": {
"bucket_sort": {
"sort": [ "cancelation_count" ],
"size": 4
}
}
}
}
},
"size": 0
}
Logs (if relevant)
Example result (filters aggregations are not sorted via the sum:cancelation_count but instead via the bucket key):
{
"took": 620,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 9580162,
"max_score": 0,
"hits": []
},
"aggregations": {
"Category": {
"buckets": {
"165422": {
"doc_count": 5835212,
"cancelation_count": {
"value": 145488
}
},
"165523": {
"doc_count": 1974874,
"cancelation_count": {
"value": 43586
}
},
"165530": {
"doc_count": 1231949,
"cancelation_count": {
"value": 33821
}
},
"171229": {
"doc_count": 193478,
"cancelation_count": {
"value": 5939
}
}
}
}
}
}