# Fetch all matching facets

**URL:** <https://discuss.elastic.co/t/fetch-all-matching-facets/11797>\
**Category:** Elasticsearch\
**Created:** [May 3, 2013, 10:49am UTC](https://discuss.elastic.co/t/fetch-all-matching-facets/11797 "2013-05-03T10:49:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aash\_dhariya](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@aash\_dhariya](https://discuss.elastic.co/u/aash_dhariya)\
**Post date:** [May 3, 2013, 10:49am UTC](https://discuss.elastic.co/t/fetch-all-matching-facets/11797/1 "2013-05-03T10:49:21Z")

</div>

Is there are way to fetch all matching facets in elasticsearch query.  
According to the link given here:  
[http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet/](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet/)  
it is possible to get the facet which N size. But what if I want to get all  
matching facets?

I tried specifying "size: 0" in my facet query, but that didn't seem to  
work.

Here is my sample ES query  
query: {  
..  
}  
facets: {  
company: {  
terms: {  
field: "company"  
size: _N_  
}  
}  
}

--  
Thanks,  
Aash

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [May 15, 2013, 3:35pm UTC](https://discuss.elastic.co/t/fetch-all-matching-facets/11797/2 "2013-05-15T15:35:12Z")

</div>

Hi Aash,

Sadly, there is currently no official way of getting all the terms which  
have a count\>0 . Of course you can cheat by using a very high size  
parameter (like 1000 or 10K or what ever you think you application  
consideres close enough to all). If you need a complete picture, you can  
use the all\_terms:true option to get a complete list of _all_ terms, even  
those who has 0 count in the result set. Watch out for performance problems  
if your field a very large number of terms in the index.

Cheers,  
Boaz

On Friday, May 3, 2013 12:49:21 PM UTC+2, geeky\_sh wrote:

> Is there are way to fetch all matching facets in elasticsearch query.  
> According to the link given here:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet/)  
> it is possible to get the facet which N size. But what if I want to get  
> all matching facets?
> 
> I tried specifying "size: 0" in my facet query, but that didn't seem to  
> work.
> 
> Here is my sample ES query  
> query: {  
> ..  
> }  
> facets: {  
> company: {  
> terms: {  
> field: "company"  
> size: _N_  
> }  
> }  
> }
> 
> --  
> Thanks,  
> Aash

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:36am UTC](https://discuss.elastic.co/t/fetch-all-matching-facets/11797/3 "2017-07-06T02:36:29Z")

</div>


