# Aggregations on Subset of Queries

**URL:** <https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002>\
**Category:** Elasticsearch\
**Created:** [March 31, 2016, 10:30pm UTC](https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002 "2016-03-31T22:30:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rn\_devs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rn_devs/32/8641_2.png) [@rn\_devs](https://discuss.elastic.co/u/rn_devs)\
**Post date:** [March 31, 2016, 10:30pm UTC](https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002/1 "2016-03-31T22:30:04Z")

</div>

Hi,

I am wondering if it is possible to run aggregations on a subset of your queries. For example, I have facet filters where I want the counts to persist when someone clicks the various filters. The filters would obviously affect the documents that get returned but I want the counts to remain as if that filter were not applied. The counts would only change if someone changed their search in the free form text search.

Is this possible?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [April 1, 2016, 7:53am UTC](https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002/2 "2016-04-01T07:53:30Z")

</div>

I think you are looking for the `post_filter` feature: [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-post-filter.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-post-filter.html)  
[https://www.elastic.co/guide/en/elasticsearch/guide/master/\_post\_filter.html](https://www.elastic.co/guide/en/elasticsearch/guide/master/_post_filter.html)

Hope that helps

---

<div class="post-metadata">

**Author:** ![rn\_devs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rn_devs/32/8641_2.png) [@rn\_devs](https://discuss.elastic.co/u/rn_devs)\
**Post date:** [April 1, 2016, 6:53pm UTC](https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002/3 "2016-04-01T18:53:08Z")

</div>

Perfect. Exactly what I need. Thanks!

---

<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:03pm UTC](https://discuss.elastic.co/t/aggregations-on-subset-of-queries/46002/4 "2017-07-05T23:03:08Z")

</div>


