# Facet help

**URL:** <https://discuss.elastic.co/t/facet-help/6867>\
**Category:** Elasticsearch\
**Created:** [March 2, 2012, 1:22pm UTC](https://discuss.elastic.co/t/facet-help/6867 "2012-03-02T13:22:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Aurelio\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_aurelio_silva/32/2973_2.png) [@Marco\_Aurelio\_Silva](https://discuss.elastic.co/u/Marco_Aurelio_Silva)\
**Post date:** [March 2, 2012, 1:22pm UTC](https://discuss.elastic.co/t/facet-help/6867/1 "2012-03-02T13:22:28Z")

</div>

Hi There

I would like to have some help on how to do some things with elastic  
search. I have an index with a lot of products that came from some websites  
(parsed by a web crawler). I would like to show to my user some filters, so  
he can refine his search. I tried to use termFacet on product name, but it  
is returning some terms that I don't want to show in the filter. What is  
the best approach to do this? Is there a way to query how many know terms I  
have in a search result?

Sorry if this doubt is too basic, I don't know where to ask this. Any help  
is appreciated!

Thanks in advance  
Marco Silva

---

<div class="post-metadata">

**Author:** ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)\
**Post date:** [March 3, 2012, 3:25pm UTC](https://discuss.elastic.co/t/facet-help/6867/2 "2012-03-03T15:25:08Z")

</div>

Hi Marco,

On Mar 2, 3:22 pm, Marco Aurélio Silva [marc...@gmail.com](mailto:marc...@gmail.com) wrote:

> Hi There
> 
> I would like to have some help on how to do some things with elastic  
> search. I have an index with a lot of products that came from some websites  
> (parsed by a web crawler). I would like to show to my user some filters, so  
> he can refine his search. I tried to use termFacet on product name, but it  
> is returning some terms that I don't want to show in the filter.

You can exclude terms that you don't want shown. See "Excluding terms"  
here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Although I'm not sure this is what you want :-s

> What is  
> the best approach to do this? Is there a way to query how many know terms I  
> have in a search result?

I'm not sure if it's just me, but I'm not sure what you're trying to  
accomplish. Can you rephrase your questions? Maybe come up with an  
example?

> Sorry if this doubt is too basic, I don't know where to ask this. Any help  
> is appreciated!
> 
> Thanks in advance  
> Marco Silva

---

<div class="post-metadata">

**Author:** ![Marco\_Aurelio\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_aurelio_silva/32/2973_2.png) [@Marco\_Aurelio\_Silva](https://discuss.elastic.co/u/Marco_Aurelio_Silva)\
**Post date:** [March 5, 2012, 7:58pm UTC](https://discuss.elastic.co/t/facet-help/6867/3 "2012-03-05T19:58:28Z")

</div>

Hi Radu

Thanks for the reply! Let me try to explain with an example:

When user search for car, I would like to show filters like:

mbw (3)  
ford (5)  
ferrari (1)

The problem is I don't know the car brand, I just have the name and a  
description. If I put a termFace on name or description, it can return  
other therms that are not brands... like wheels or some other word that is  
common for all cars... right?  
What I want to do is, from a list of pre defined brands, know the number of  
each on the search result...

Is a good aproach ti create a termFacet for each brand, with a filter on it  
(to limit to the brand name)?

On Sat, Mar 3, 2012 at 12:25 PM, Radu Gheorghe [radu0gheorghe@gmail.com](mailto:radu0gheorghe@gmail.com)wrote:

> Hi Marco,
> 
> On Mar 2, 3:22 pm, Marco Aurélio Silva [marc...@gmail.com](mailto:marc...@gmail.com) wrote:
> 
> > Hi There
> > 
> > I would like to have some help on how to do some things with elastic  
> > search. I have an index with a lot of products that came from some  
> > websites  
> > (parsed by a web crawler). I would like to show to my user some filters,  
> > so  
> > he can refine his search. I tried to use termFacet on product name, but  
> > it  
> > is returning some terms that I don't want to show in the filter.
> 
> You can exclude terms that you don't want shown. See "Excluding terms"  
> here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)
> 
> Although I'm not sure this is what you want :-s
> 
> > What is  
> > the best approach to do this? Is there a way to query how many know  
> > terms I  
> > have in a search result?
> 
> I'm not sure if it's just me, but I'm not sure what you're trying to  
> accomplish. Can you rephrase your questions? Maybe come up with an  
> example?
> 
> > Sorry if this doubt is too basic, I don't know where to ask this. Any  
> > help  
> > is appreciated!
> > 
> > Thanks in advance  
> > Marco Silva

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [March 6, 2012, 8:25am UTC](https://discuss.elastic.co/t/facet-help/6867/4 "2012-03-06T08:25:44Z")

</div>

well, ElasticSearch cannot do the guess work for you so you'll need to  
extract the brand name yourself (from your predefined list - its easy).  
then feed it into a brand field ...

Does this help?

Peter.

---

<div class="post-metadata">

**Author:** ![Marco\_Aurelio\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_aurelio_silva/32/2973_2.png) [@Marco\_Aurelio\_Silva](https://discuss.elastic.co/u/Marco_Aurelio_Silva)\
**Post date:** [March 6, 2012, 3:38pm UTC](https://discuss.elastic.co/t/facet-help/6867/5 "2012-03-06T15:38:22Z")

</div>

Hi Peter

This is what I want to know... is this the right way to do this? Get the  
list of terms and see if it is a predefined brand? I'm afraid I have only  
one document for one brand, and this term could not be returned right?  
Sorry, I have never worked with lucene or elasticsearch before, things are  
not clear to me 😉

Thank you  
Marco

On Tue, Mar 6, 2012 at 5:25 AM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> well, Elasticsearch cannot do the guess work for you so you'll need to  
> extract the brand name yourself (from your predefined list - its easy).  
> then feed it into a brand field ...
> 
> Does this help?
> 
> Peter.

---

<div class="post-metadata">

**Author:** ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)\
**Post date:** [March 7, 2012, 11:33am UTC](https://discuss.elastic.co/t/facet-help/6867/6 "2012-03-07T11:33:52Z")

</div>

Hi Marco,

I'm too much of a noob to tell you if there's a right way to do this,  
unfortunately.

What I would do is to define one filter facet for each brand in the  
predefined list. Then I would run the query with all the facets there.

A bit more on filter facets here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

I hope this helps.

On Mar 5, 9:58 pm, Marco Aurélio Silva [marc...@gmail.com](mailto:marc...@gmail.com) wrote:

> Hi Radu
> 
> Thanks for the reply! Let me try to explain with an example:
> 
> When user search for car, I would like to show filters like:
> 
> mbw (3)  
> ford (5)  
> ferrari (1)
> 
> The problem is I don't know the car brand, I just have the name and a  
> description. If I put a termFace on name or description, it can return  
> other therms that are not brands... like wheels or some other word that is  
> common for all cars... right?  
> What I want to do is, from a list of pre defined brands, know the number of  
> each on the search result...
> 
> Is a good aproach ti create a termFacet for each brand, with a filter on it  
> (to limit to the brand name)?
> 
> On Sat, Mar 3, 2012 at 12:25 PM, Radu Gheorghe [radu0gheor...@gmail.com](mailto:radu0gheor...@gmail.com)wrote:
> 
> > Hi Marco,
> 
> > On Mar 2, 3:22 pm, Marco Aurélio Silva [marc...@gmail.com](mailto:marc...@gmail.com) wrote:
> > 
> > > Hi There
> 
> > > I would like to have some help on how to do some things with elastic  
> > > search. I have an index with a lot of products that came from some  
> > > websites  
> > > (parsed by a web crawler). I would like to show to my user some filters,  
> > > so  
> > > he can refine his search. I tried to use termFacet on product name, but  
> > > it  
> > > is returning some terms that I don't want to show in the filter.
> 
> > You can exclude terms that you don't want shown. See "Excluding terms"  
> > here:
> 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-)...
> 
> > Although I'm not sure this is what you want :-s
> 
> > > What is  
> > > the best approach to do this? Is there a way to query how many know  
> > > terms I  
> > > have in a search result?
> 
> > I'm not sure if it's just me, but I'm not sure what you're trying to  
> > accomplish. Can you rephrase your questions? Maybe come up with an  
> > example?
> 
> > > Sorry if this doubt is too basic, I don't know where to ask this. Any  
> > > help  
> > > is appreciated!
> 
> > > Thanks in advance  
> > > Marco Silva

---

<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:36am UTC](https://discuss.elastic.co/t/facet-help/6867/7 "2017-07-06T03:36:55Z")

</div>


