When using pipeline aggregations, there are useless returned values which consumpt too much memory.
Take the below query as example.
{
"aggs" : {
"sales_per_month" : {
"date_histogram" : {
"field" : "date",
"interval" : "month"
},
"aggs": {
"total_sales": {
"sum": {
"field": "price"
}
},
"t-shirts": {
"filter": {
"term": {
"type": "t-shirt"
}
},
"aggs": {
"sales": {
"sum": {
"field": "price"
}
}
}
},
"t-shirt-percentage": {
"bucket_script": {
"buckets_path": {
"tShirtSales": "t-shirts>sales",
"totalSales": "total_sales"
},
"script": "tShirtSales / totalSales * 100"
}
}
}
}
}
}
In this case, only "t-shirt-percentage" pipeline aggregation measure is in need. All the other measures are useless. Is there a way to filter out the useless measures before ES return to decrease the memory consumption of the query result?