Hello
I need to calculate a ratio between 2 aggregation.
This is my request
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "MERCH_YEAR:2016",
"analyze_wildcard": true
}
},
"filter": {
"bool": {
"must": [
{
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "MERCH_YEAR:2016"
}
}
}
],
"must_not": []
}
}
}
},
"size": 0,
"aggs": {
"total_qty": {
"sum": {
"field": "SALES_QTY"
}
},
"total_sales": {
"sum": {
"field": "SALES_EURO"
}
},
"AUR": {
"bucket_script": {
"buckets_path": {
"my_var1": "total_sales",
"my_var2": "total_qty"
},
"script": "my_var1 / my_var2"
}
}
}
}
But I get this error : nvalid pipeline aggregation named [AUR] of type [bucket_script]. Only sibling pipeline aggregations are allowed at the top level.
How can I get the right result?
Thanks
Lorenzo