Calculate Percentage for a field inside Aggregation


#1

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


(md furqan) #2

I too have the same problem
Please help in resolving this.


(system) #3