I am trying to use bucket_sort, but i am not sure if it's working correctly.
"aggs": {
"group_by_phone": {
"terms": {
"field": "phoneNumber.keyword"
},
"aggs": {
"totalTnxAmount": {
"sum": {
"field": "amount"
}
},
"sales_bucket_sort": {
"bucket_sort": {
"sort": [
{
"totalTnxAmount": {
"order": "desc"
}
}
]
}
},
"aggs": {
"top_hits": {
"_source": [
"firstName",
"lastName"
],
"size": 1
}
}
}
}
}
Please can anyone tell me if anything is wrong with this aggregation