Hi,
I would like to know if we can add a script inside an aggregation?
My goal is to make a compute between fields (inside the aggregation) to get a variation.
For example:
...
"aggs":{
"group_by_product": {
"terms": {
"field": "product"
},
"script_fields": {
"test_variation": {
"script": {
"lang": "painless",
"source": "ADD A LOOP HERE FOR COMPUTATION on the field price for the same product"
}
}
}
...
And the result will be:
"aggregations" : {
"group_by_product" : {
"doc_count_error_upper_bound" : 4,
"sum_other_doc_count" : 163,
"buckets" : [
{
"key" : "apple",
"price" : 4,
"doc_count" : 29
},
{
"key" : "orange",
"price" : 3,
"doc_count" : 20