I am trying to sort the values of my aggregated results, in ascending order, to another aggregation result.
Code:
"aggregation":[
"agg_max_saving_percent"=> [
"terms"=> [
"field"=> 'key',
'size' => 60,
'order' => [ 'maximma' => 'desc' ]
],
"aggs"=> [
"offers"=> [
"nested"=> [
"path"=> "offers"
],
"aggs"=> [
"found_savper"=> [
"max"=> [
"field"=> "offers.savper"
]
]
],
]
],
"aggs"=> [ "maximma" => ["max" => ['field' => "sum_score"]]],
]
]
Mapping:
"offers": {
"type": "nested",
"properties": {
"savper": {"type": "long"}
}
}
"sum_score": {"type": "long"},
At the moment, I am only getting the results of 'MAXIMA', with which I am sorting and not the results of 'found_savper'
Although, I need the results of found_savper and want the bucket to be sorted by maxima desc. Any suggestions?