# Restricting the terms returned in facets

**URL:** <https://discuss.elastic.co/t/restricting-the-terms-returned-in-facets/9620>\
**Category:** Elasticsearch\
**Created:** [November 8, 2012, 5:27am UTC](https://discuss.elastic.co/t/restricting-the-terms-returned-in-facets/9620 "2012-11-08T05:27:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atharva\_Patel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atharva_patel/32/2414_2.png) [@Atharva\_Patel](https://discuss.elastic.co/u/Atharva_Patel)\
**Post date:** [November 8, 2012, 5:27am UTC](https://discuss.elastic.co/t/restricting-the-terms-returned-in-facets/9620/1 "2012-11-08T05:27:40Z")

</div>

Hi,

I am interested in computing the terms count across all the documents, but  
want to return the terms which are present in a particular field of the  
documents matching with filter/query.

The documentation talks about various methods like restricting the  
documents considered while computing the results, which is quite different  
than what I am looking for.

A use case can be like getting the counts of all the terms present in a  
particular filtered document to calculate their idf(or such aggregate  
statistics) of individual terms present in some field.

How can this be achieved?

--

---

<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 6, 2017, 3:05am UTC](https://discuss.elastic.co/t/restricting-the-terms-returned-in-facets/9620/2 "2017-07-06T03:05:31Z")

</div>


