How can we calculate percentage of field inside an aggregation?
Aggregation Query
{ "size": 0, "aggs": { "field_1": { "terms": { "field": "field_1" }, "field_2": { "sum": { "script": "doc['field_3'].value + doc['field_4'].value" } } } } }
Now we want to calculate percentage using something like this
(doc['field_4'].value/ doc['field_5'].value)*100