I have below search
POST /MY_ID/_search?typed_keys=true
{
"aggs": {
"terms_agg": {
"terms": {
"field": "[RefNumber]"
},
"aggs": {
"max_agg_startdate": {
"max": {
"field": "StartDate"
}
},
"max_agg_enddate": {
"max": {
"field": "Enddate"
}
}
}
}
},
...
...
I want to accesss buckets returned from Max aggregations max_agg_startdate & max_agg_enddate in upper level. Requirement is get the average difference between max_agg_startdate and max_agg_enddate. Lets say this calculation performs just above the "terms_agg", how do I get access to max_agg_startdate & max_agg_enddate from that level?
Thanks