# Faceted Search Basics

**URL:** <https://discuss.elastic.co/t/faceted-search-basics/2977>\
**Category:** Elasticsearch\
**Created:** [May 26, 2010, 12:57pm UTC](https://discuss.elastic.co/t/faceted-search-basics/2977 "2010-05-26T12:57:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elljoh\_2](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@elljoh\_2](https://discuss.elastic.co/u/elljoh_2)\
**Post date:** [May 26, 2010, 12:57pm UTC](https://discuss.elastic.co/t/faceted-search-basics/2977/1 "2010-05-26T12:57:18Z")

</div>

Hi,

I was encouraged to learn that Elastic supports facets.

Given a search result set, I would like to have access to the distinct  
values of facets to drive dimensional pivots through browsing the  
results: even if the distinct value set for a facet is the values of a  
particular field. err...What does "he" mean?...

e.g. Say I have a product inventory catalog that contains fields such  
as {desc,location, type, msrp}.

If a user searches for "desc" : "frotz", and that result set contains  
1000 hits, I want to have "buckets" of distinct values for those hits  
in facets for {location, type, msrp} in the results. This will help in  
directing the user for subsequent query refinement (would be nice to  
have range buckets for numerics such as msrp).

However, looking at the the facet examples on  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/) I  
only see a facet query for specific terms and the result is a count of  
hits for that query. I wont know distinct valid values for a facet;  
this is what I would like Elastic to tell me as part of the search  
results 🙂

Is there a way to achieve what I describe above with facets using a  
different query DSL spec inside the facet? e.g. a wildcard or  
something else. Or is there a different common practice to achieve  
this in Elastic?...

Cheers, elljoh

ps: (inadvertently posted on the nabble mirror...hope the plumbing is  
correct now 😉 apologies for the dupe...)

---

<div class="post-metadata">

**Author:** ![Bart\_Schuller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bart_schuller/32/3338_2.png) [@Bart\_Schuller](https://discuss.elastic.co/u/Bart_Schuller)\
**Post date:** [May 26, 2010, 2:12pm UTC](https://discuss.elastic.co/t/faceted-search-basics/2977/2 "2010-05-26T14:12:18Z")

</div>

On May 26, 2010, at 14:57, elljoh wrote:

> However, looking at the the facet examples on  
> [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/) I  
> only see a facet query for specific terms and the result is a count of  
> hits for that query. I wont know distinct valid values for a facet;  
> this is what I would like Elastic to tell me as part of the search  
> results 🙂

It's a two-step process. The distinct values can be fetched first using the Terms API [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/terms/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/terms/)

It would be nice if there was a way to combine facets with terms so you could say: query for this facet for all the terms available in the index.

--  
[Bart.Schuller@gmail.com](mailto:Bart.Schuller@gmail.com)

---

<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:** [May 26, 2010, 11:35pm UTC](https://discuss.elastic.co/t/faceted-search-basics/2977/3 "2010-05-26T23:35:16Z")

</div>

Agreed, thats the best way to solve this now. I completely agree with the  
requirement, and this is the type of requirements I think facets need to  
support (I don't even place them under a facet). I have an idea on how to  
implement that and several other features (like custom scoring), but it  
requires building a bit of infrastructure for it.

I am working on it, first mentally ;), and then will code it. It is  
certainly on my road map, and really eager to do it. One thing to note here  
(and it applies to geo support as well) is that next Lucene version has made  
substantial changes in those areas, so its delicate to implement this and  
make sure to maintain backward compatibility.

On Wed, May 26, 2010 at 5:12 PM, Bart Schuller [Bart.Schuller@gmail.com](mailto:Bart.Schuller@gmail.com)wrote:

> On May 26, 2010, at 14:57, elljoh wrote:
> 
> > However, looking at the the facet examples on  
> > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/) I  
> > only see a facet query for specific terms and the result is a count of  
> > hits for that query. I wont know distinct valid values for a facet;  
> > this is what I would like Elastic to tell me as part of the search  
> > results 🙂
> 
> It's a two-step process. The distinct values can be fetched first using the  
> Terms API [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/terms/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/terms/)
> 
> It would be nice if there was a way to combine facets with terms so you  
> could say: query for this facet for all the terms available in the index.
> 
> --  
> [Bart.Schuller@gmail.com](mailto:Bart.Schuller@gmail.com)

---

<div class="post-metadata">

**Author:** ![elljoh\_2](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@elljoh\_2](https://discuss.elastic.co/u/elljoh_2)\
**Post date:** [May 27, 2010, 10:15am UTC](https://discuss.elastic.co/t/faceted-search-basics/2977/4 "2010-05-27T10:15:41Z")

</div>

Thanks guys...

Clarification much appreciated.

Will be keenly following the facet (or other pending name ;)...) other  
road map. For now the bifurcated process will work just fine. Also  
understood is the careful approach to maintaining consistency with the  
direction that similar features take within Lucene.

Thanks again...See you on the list...

Cheers, elljoh

On May 27, 9:35 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Agreed, thats the best way to solve this now. I completely agree with the  
> requirement, and this is the type of requirements I think facets need to  
> support (I don't even place them under a facet). I have an idea on how to  
> implement that and several other features (like custom scoring), but it  
> requires building a bit of infrastructure for it.
> 
> I am working on it, first mentally ;), and then will code it. It is  
> certainly on my road map, and really eager to do it. One thing to note here  
> (and it applies to geo support as well) is that next Lucene version has made  
> substantial changes in those areas, so its delicate to implement this and  
> make sure to maintain backward compatibility.
> 
> On Wed, May 26, 2010 at 5:12 PM, Bart Schuller [Bart.Schul...@gmail.com](mailto:Bart.Schul...@gmail.com)wrote:
> 
> > On May 26, 2010, at 14:57, elljoh wrote:
> 
> > > However, looking at the the facet examples on  
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/I](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/I)  
> > > only see a facet query for specific terms and the result is a count of  
> > > hits for that query. I wont know distinct valid values for a facet;  
> > > this is what I would like Elastic to tell me as part of the search  
> > > results 🙂
> 
> > It's a two-step process. The distinct values can be fetched first using the  
> > Terms APIhttp://www.elasticsearch.com/docs/elasticsearch/rest\_api/terms/
> 
> > It would be nice if there was a way to combine facets with terms so you  
> > could say: query for this facet for all the terms available in the index.
> 
> > --  
> > [Bart.Schul...@gmail.com](mailto:Bart.Schul...@gmail.com)

---

<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:23am UTC](https://discuss.elastic.co/t/faceted-search-basics/2977/5 "2017-07-06T04:23:45Z")

</div>


