# Elasticsearch bucket aggreation with filters on returned buckets

**URL:** <https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315>\
**Category:** Elasticsearch\
**Created:** [November 23, 2015, 2:57pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315 "2015-11-23T14:57:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nipun](https://avatars.discourse-cdn.com/v4/letter/n/85f322/32.png) [@Nipun](https://discuss.elastic.co/u/Nipun)\
**Post date:** [November 23, 2015, 2:57pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315/1 "2015-11-23T14:57:17Z")

</div>

I have posted a question on Stack overflow regarding the problem. Here is the link [http://stackoverflow.com/questions/33873625/how-do-we-bucket-aggregate-only-on-the-matched-prefix-on-elasticsearch](http://stackoverflow.com/questions/33873625/how-do-we-bucket-aggregate-only-on-the-matched-prefix-on-elasticsearch)

Can anyone please help me with the problem?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 23, 2015, 3:23pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315/2 "2015-11-23T15:23:25Z")

</div>

I suppose the "include" feature of terms aggs would do the job? [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#\_filtering\_values\_2](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values_2)

---

<div class="post-metadata">

**Author:** ![Nipun](https://avatars.discourse-cdn.com/v4/letter/n/85f322/32.png) [@Nipun](https://discuss.elastic.co/u/Nipun)\
**Post date:** [November 23, 2015, 3:42pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315/3 "2015-11-23T15:42:27Z")

</div>

Thanks. That was it.

---

<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, 11:36pm UTC](https://discuss.elastic.co/t/elasticsearch-bucket-aggreation-with-filters-on-returned-buckets/35315/4 "2017-07-05T23:36:33Z")

</div>


