ElasticSearch: greater between two aggregations -
i'm new elasticsearch , trying greater value between 2 aggregations, possible? need greater between avg_field1 , avg_field2. i thinking in try use script: max , didn't find example of usage.. don't know if it's possible. my aggregations now: { "aggs" : { "group_by_frame" : { "histogram" : { "field" : "index_histogram", "interval" : 100 }, "aggs" : { "avg_field1" : { "avg" : { "field" : "field1" } }, "avg_field2" : { "avg" : { "field" : "field2" } } } } } please see answer here: elastic search sum of aggregated values basically cannot aggregate on different aggregations.