I am using elastic search 5.5.1. My requirement is to apply following formula : (doc_count*100/10) on below set of data :
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 13,
"max_score": 0,
"hits": []
},
"aggregations": {
"group_by_botId": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1,
"doc_count": 9
},
{
"key": 3,
"doc_count": 4
}
]
}
}
}
I should be able to find solution for each bucket items. I don't want to use Java SDK for this problem as requirement is to use only elastic search REST API.
You can use the
bucket_script
aggregation in order to run a script for each bucket: