# How to configure TermsFacet?

**URL:** <https://discuss.elastic.co/t/how-to-configure-termsfacet/3667>\
**Category:** Elasticsearch\
**Created:** [December 15, 2010, 5:02pm UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667 "2010-12-15T17:02:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [December 15, 2010, 5:02pm UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/1 "2010-12-15T17:02:03Z")

</div>

Hello

I have following usecase:  
I'd like to create TermsFacet which will return all possible terms  
(just like global facet), but numbers should be taken from current  
query/filtering (just like in non-global facet).  
In other words: my facet should work just like usual non-global  
TermsFacet, but in results there should be always all possible terms  
for particular field (probably most of them with count 0).

How to achieve this functionality? Maybe it should be included in ES  
just like global facets are?

Regards  
Wojciech Durczyński

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 16, 2010, 7:18pm UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/2 "2010-12-16T19:18:20Z")

</div>

There isn't an option to do this today. How many terms are we talking about  
per field (in general)?

2010/12/15 Wojciech Durczyński [wojciech.durczynski@comarch.com](mailto:wojciech.durczynski@comarch.com)

> Hello
> 
> I have following usecase:  
> I'd like to create TermsFacet which will return all possible terms  
> (just like global facet), but numbers should be taken from current  
> query/filtering (just like in non-global facet).  
> In other words: my facet should work just like usual non-global  
> TermsFacet, but in results there should be always all possible terms  
> for particular field (probably most of them with count 0).
> 
> How to achieve this functionality? Maybe it should be included in ES  
> just like global facets are?
> 
> Regards  
> Wojciech Durczyński

---

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [December 16, 2010, 11:12pm UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/3 "2010-12-16T23:12:59Z")

</div>

That's only for category purposes (not analyzed text field) so I think  
it'd be usually less than 10 terms.  
I'd like to implement an object browser with facet-based filtering.  
When somebody restricts search to objects of one category, then other  
categories should be returned also for him to change his selection.

Additionally it would be perfect to have a possibility of defining two  
types of filters:  
strong filters - one kind of filter that always restricts browsed  
objects (user isn't allowed to see these objects at all)  
weak filters - second kind of filter that limits browsed objects (user  
selects a filter to limit shown objects).

Then facet values should be calculated that way:

1. documents in index are restricted by strong filters
2. check what terms exists in those set of documents - they will be  
facet values (terms) to return
3. restrict documents by weak filters
4. calculate document counts for terms from 2. and return all those  
values (even zeros)

What do you think about that functionality? Is it possible to  
implement?

On Dec 16, 8:18 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> There isn't an option to do this today. How many terms are we talking about  
> per field (in general)?
> 
> 2010/12/15 Wojciech Durczyński [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com)
> 
> > Hello
> 
> > I have following usecase:  
> > I'd like to create TermsFacet which will return all possible terms  
> > (just like global facet), but numbers should be taken from current  
> > query/filtering (just like in non-global facet).  
> > In other words: my facet should work just like usual non-global  
> > TermsFacet, but in results there should be always all possible terms  
> > for particular field (probably most of them with count 0).
> 
> > How to achieve this functionality? Maybe it should be included in ES  
> > just like global facets are?
> 
> > Regards  
> > Wojciech Durczyński

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 19, 2010, 12:46am UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/4 "2010-12-19T00:46:59Z")

</div>

Heya,

Its certainly possible to implement. Can you open an issue for this? I  
plan to work more on facets to make them more easily pluggable and  
extensible, and this can be one of the enhancements.

-shay.banon

2010/12/17 Wojciech Durczyński [wojciech.durczynski@comarch.com](mailto:wojciech.durczynski@comarch.com)

> That's only for category purposes (not analyzed text field) so I think  
> it'd be usually less than 10 terms.  
> I'd like to implement an object browser with facet-based filtering.  
> When somebody restricts search to objects of one category, then other  
> categories should be returned also for him to change his selection.
> 
> Additionally it would be perfect to have a possibility of defining two  
> types of filters:  
> strong filters - one kind of filter that always restricts browsed  
> objects (user isn't allowed to see these objects at all)  
> weak filters - second kind of filter that limits browsed objects (user  
> selects a filter to limit shown objects).
> 
> Then facet values should be calculated that way:
> 
> 1. documents in index are restricted by strong filters
> 2. check what terms exists in those set of documents - they will be  
> facet values (terms) to return
> 3. restrict documents by weak filters
> 4. calculate document counts for terms from 2. and return all those  
> values (even zeros)
> 
> What do you think about that functionality? Is it possible to  
> implement?
> 
> On Dec 16, 8:18 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > There isn't an option to do this today. How many terms are we talking  
> > about  
> > per field (in general)?
> > 
> > 2010/12/15 Wojciech Durczyński [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com)
> > 
> > > Hello
> > 
> > > I have following usecase:  
> > > I'd like to create TermsFacet which will return all possible terms  
> > > (just like global facet), but numbers should be taken from current  
> > > query/filtering (just like in non-global facet).  
> > > In other words: my facet should work just like usual non-global  
> > > TermsFacet, but in results there should be always all possible terms  
> > > for particular field (probably most of them with count 0).
> > 
> > > How to achieve this functionality? Maybe it should be included in ES  
> > > just like global facets are?
> > 
> > > Regards  
> > > Wojciech Durczyński

---

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [December 20, 2010, 12:48pm UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/5 "2010-12-20T12:48:05Z")

</div>

Issue created:

> <https://github.com/elastic/elasticsearch/issues/570>
>
> I'd like to create TermsFacet which will return all possible terms
> (just like gl…obal facet), but numbers should be taken from current
> query/filtering (just like in non-global facet).
> In other words: my facet should work just like usual non-global
> TermsFacet, but in results there should be always all possible terms
> for particular field (probably most of them with count 0).
> That's only for category purposes (not analyzed text field) so I think
> it'd be usually less than 10 terms.
> 
> That kind of facet is needed to implement an object browser with facet-based filtering.
> When somebody restricts search to objects of one category, then other
> categories should be returned also for him to change his selection.
> 
> Additionally it would be perfect to have a possibility of defining two
> types of filters:
> strong filters - one kind of filter that always restricts browsed
> objects (user isn't allowed to see these objects at all)
> weak filters - second kind of filter that limits browsed objects (user
> selects a filter to limit shown objects).
> 
> Then facet values should be calculated that way:
> 1. documents in index are restricted by strong filters
> 2. check what terms exists in those set of documents - they will be
> facet values (terms) to return
> 3. restrict documents by weak filters
> 4. calculate document counts for terms from 2. and return all those
> values (even zeros) 
> 
> Issue created because of thread:
> http://groups.google.com/a/elasticsearch.com/group/users/browse\_thread/thread/39a45b70516a68a9/

On Dec 19, 1:46 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Heya,
> 
> Its certainly possible to implement. Can you open an issue for this? I  
> plan to work more on facets to make them more easily pluggable and  
> extensible, and this can be one of the enhancements.
> 
> -shay.banon
> 
> 2010/12/17 Wojciech Durczyński [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com)
> 
> > That's only for category purposes (not analyzed text field) so I think  
> > it'd be usually less than 10 terms.  
> > I'd like to implement an object browser with facet-based filtering.  
> > When somebody restricts search to objects of one category, then other  
> > categories should be returned also for him to change his selection.
> 
> > Additionally it would be perfect to have a possibility of defining two  
> > types of filters:  
> > strong filters - one kind of filter that always restricts browsed  
> > objects (user isn't allowed to see these objects at all)  
> > weak filters - second kind of filter that limits browsed objects (user  
> > selects a filter to limit shown objects).
> 
> > Then facet values should be calculated that way:
> > 
> > 1. documents in index are restricted by strong filters
> > 2. check what terms exists in those set of documents - they will be  
> > facet values (terms) to return
> > 3. restrict documents by weak filters
> > 4. calculate document counts for terms from 2. and return all those  
> > values (even zeros)
> 
> > What do you think about that functionality? Is it possible to  
> > implement?
> 
> > On Dec 16, 8:18 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > There isn't an option to do this today. How many terms are we talking  
> > > about  
> > > per field (in general)?
> 
> > > 2010/12/15 Wojciech Durczyński [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com)
> 
> > > > Hello
> 
> > > > I have following usecase:  
> > > > I'd like to create TermsFacet which will return all possible terms  
> > > > (just like global facet), but numbers should be taken from current  
> > > > query/filtering (just like in non-global facet).  
> > > > In other words: my facet should work just like usual non-global  
> > > > TermsFacet, but in results there should be always all possible terms  
> > > > for particular field (probably most of them with count 0).
> 
> > > > How to achieve this functionality? Maybe it should be included in ES  
> > > > just like global facets are?
> 
> > > > Regards  
> > > > Wojciech Durczyński

---

<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, 4:15am UTC](https://discuss.elastic.co/t/how-to-configure-termsfacet/3667/6 "2017-07-06T04:15:07Z")

</div>


