# How to filter out useless aggregation result when using pipeline aggregations

**URL:** <https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930>\
**Category:** Elasticsearch\
**Created:** [July 7, 2016, 9:38am UTC](https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930 "2016-07-07T09:38:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangke](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zhangke](https://discuss.elastic.co/u/zhangke)\
**Post date:** [July 7, 2016, 9:38am UTC](https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930/1 "2016-07-07T09:38:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 7, 2016, 9:57am UTC](https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930/2 "2016-07-07T09:57:34Z")

</div>

Hi,

I'm not sure I understand the question correctly, what do do you mean by "the other measures are useless"? It looks like you need them for the script? If you only want to filter out the aggregation results in the query response, take a look at [Respone Filtering](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#_response_filtering), maybe that helps.

---

<div class="post-metadata">

**Author:** ![zhangke](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zhangke](https://discuss.elastic.co/u/zhangke)\
**Post date:** [July 8, 2016, 6:58am UTC](https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930/4 "2016-07-08T06:58:06Z")

</div>

Get it!

Thanks for your kindly help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:37pm UTC](https://discuss.elastic.co/t/how-to-filter-out-useless-aggregation-result-when-using-pipeline-aggregations/54930/5 "2017-07-05T22:37:10Z")

</div>


