# Filter results by aggregation value

**URL:** <https://discuss.elastic.co/t/filter-results-by-aggregation-value/150245>\
**Category:** Elasticsearch\
**Created:** [September 27, 2018, 7:14pm UTC](https://discuss.elastic.co/t/filter-results-by-aggregation-value/150245 "2018-09-27T19:14:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aylan\_Devmedia](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@Aylan\_Devmedia](https://discuss.elastic.co/u/Aylan_Devmedia)\
**Post date:** [September 27, 2018, 7:14pm UTC](https://discuss.elastic.co/t/filter-results-by-aggregation-value/150245/1 "2018-09-27T19:14:35Z")

</div>

Is there a way to use a value provided by an aggregation to make another layer of filtering?

I'm making a standard query that search the incidence of terms in two fields, and wish to show only the docs whose `_score` is above or equal the average that I can get in the aggs.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 28, 2018, 8:17am UTC](https://discuss.elastic.co/t/filter-results-by-aggregation-value/150245/2 "2018-09-28T08:17:14Z")

</div>

[Top hits](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html) aggregation might be of use

---

<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:** [October 26, 2018, 8:17am UTC](https://discuss.elastic.co/t/filter-results-by-aggregation-value/150245/3 "2018-10-26T08:17:15Z")

</div>

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