# Search: Filter data after an aggregation

**URL:** <https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760>\
**Category:** Elasticsearch\
**Created:** [April 11, 2023, 3:32pm UTC](https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760 "2023-04-11T15:32:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gutierrezfj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gutierrezfj/32/92727_2.png) [@gutierrezfj](https://discuss.elastic.co/u/gutierrezfj)\
**Post date:** [April 11, 2023, 3:32pm UTC](https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760/1 "2023-04-11T15:32:48Z")

</div>

Hi community.  
I have made a query to obtain the average number of bytes per browser type, but I require that only the data that has an average less than 5000 be displayed or retrieved.  
I have read a lot but nothing concrete about how to filter AFTER doing an aggregation with numerical data, (filtering after...not before).  
If anyone has the answer, I'd be deeply grateful.

---

<div class="post-metadata">

**Author:** ![TimBosman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timbosman/32/84120_2.png) [@TimBosman](https://discuss.elastic.co/u/TimBosman)\
**Post date:** [April 12, 2023, 8:44am UTC](https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760/2 "2023-04-12T08:44:36Z")

</div>

Hey,

I think you are looking for the [Bucket Selector aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html).

Please let me know if it is what you were looking for,

Tim

---

<div class="post-metadata">

**Author:** ![gutierrezfj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gutierrezfj/32/92727_2.png) [@gutierrezfj](https://discuss.elastic.co/u/gutierrezfj)\
**Post date:** [April 12, 2023, 10:25am UTC](https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760/3 "2023-04-12T10:25:17Z")

</div>

It was the perfect solution. Thank you!

---

<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:** [May 10, 2023, 10:26am UTC](https://discuss.elastic.co/t/search-filter-data-after-an-aggregation/329760/4 "2023-05-10T10:26:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
