# Hierarchical facets

**URL:** <https://discuss.elastic.co/t/hierarchical-facets/6252>\
**Category:** Elasticsearch\
**Created:** [December 29, 2011, 3:46pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252 "2011-12-29T15:46:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Stendardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_stendardi/32/2990_2.png) [@David\_Stendardi](https://discuss.elastic.co/u/David_Stendardi)\
**Post date:** [December 29, 2011, 3:46pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/1 "2011-12-29T15:46:12Z")

</div>

Hi there !

Is there any plan to implement hierarchical facets ?  
If not we may help and contribute as we need this feature for a starting  
project  
(this feature will determine if we choose elasticsearch over solr)

Cheers,

--  
David Stendardi

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [December 30, 2011, 8:01am UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/2 "2011-12-30T08:01:49Z")

</div>

ES has a ticket for this open on Github with lots of +1s.  
Solr has a few patches for this and Wiki page(s) describing how they  
work.

Otis

On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
wrote:

> Hi there !
> 
> Is there any plan to implement hierarchical facets ?  
> If not we may help and contribute as we need this feature for a starting  
> project  
> (this feature will determine if we choose elasticsearch over solr)
> 
> Cheers,
> 
> --  
> David Stendardi

---

<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 30, 2011, 12:35pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/3 "2011-12-30T12:35:28Z")

</div>

There is a plan to support it, nothing scheduled yet though (its tricky to  
make it performant).

On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<  
[otis.gospodnetic@gmail.com](mailto:otis.gospodnetic@gmail.com)\> wrote:

> ES has a ticket for this open on Github with lots of +1s.  
> Solr has a few patches for this and Wiki page(s) describing how they  
> work.
> 
> Otis
> 
> On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> wrote:
> 
> > Hi there !
> > 
> > Is there any plan to implement hierarchical facets ?  
> > If not we may help and contribute as we need this feature for a starting  
> > project  
> > (this feature will determine if we choose elasticsearch over solr)
> > 
> > Cheers,
> > 
> > --  
> > David Stendardi

---

<div class="post-metadata">

**Author:** ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)\
**Post date:** [December 30, 2011, 2:16pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/4 "2011-12-30T14:16:03Z")

</div>

What do you define as a hierarchical facet?

I implemented hierarchical faceting by providing a parent field in my  
query when faceting. It works.  
But relies that your hierarchy be established at index time through  
fields.

On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> There is a plan to support it, nothing scheduled yet though (its tricky to  
> make it performant).
> 
> On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> 
> [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> 
> > ES has a ticket for this open on Github with lots of +1s.  
> > Solr has a few patches for this and Wiki page(s) describing how they  
> > work.
> 
> > Otis
> 
> > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > wrote:
> > 
> > > Hi there !
> 
> > > Is there any plan to implement hierarchical facets ?  
> > > If not we may help and contribute as we need this feature for a starting  
> > > project  
> > > (this feature will determine if we choose elasticsearch over solr)
> 
> > > Cheers,
> 
> > > --  
> > > David Stendardi

---

<div class="post-metadata">

**Author:** ![David\_Stendardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_stendardi/32/2990_2.png) [@David\_Stendardi](https://discuss.elastic.co/u/David_Stendardi)\
**Post date:** [December 30, 2011, 2:19pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/5 "2011-12-30T14:19:20Z")

</div>

take a look at the issue (and solr equivalent) :

> <https://github.com/elastic/elasticsearch/issues/1076>
>
> This seems to be a popular request. This feature would allow hierarchical facet…s on fields that are not necessarily numeric, thus allowing faceting that looks like this, for example:
> 
> Media Type Facets:
> \- twitter (20)
> - source: foo (12)
> - source: bar (8)
> \- facebook (14)
> - source: foo (10)
> - source: bar (4)

2011/12/30 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)

> What do you define as a hierarchical facet?
> 
> I implemented hierarchical faceting by providing a parent field in my  
> query when faceting. It works.  
> But relies that your hierarchy be established at index time through  
> fields.
> 
> On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > There is a plan to support it, nothing scheduled yet though (its tricky  
> > to  
> > make it performant).
> > 
> > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> > 
> > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > 
> > > ES has a ticket for this open on Github with lots of +1s.  
> > > Solr has a few patches for this and Wiki page(s) describing how they  
> > > work.
> > 
> > > Otis
> > 
> > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > wrote:
> > > 
> > > > Hi there !
> > 
> > > > Is there any plan to implement hierarchical facets ?  
> > > > If not we may help and contribute as we need this feature for a  
> > > > starting  
> > > > project  
> > > > (this feature will determine if we choose elasticsearch over solr)
> > 
> > > > Cheers,
> > 
> > > > --  
> > > > David Stendardi

--  
David Stendardi

---

<div class="post-metadata">

**Author:** ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)\
**Post date:** [December 30, 2011, 2:29pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/6 "2011-12-30T14:29:33Z")

</div>

I achieved that using Solr out of the box using the technique I  
mentioned above.  
In my UI, when a user "drills" down from a facet in the hierarchy, it  
issues another facet query on the fly. Works great.

On Dec 30, 9:19 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com) wrote:

> take a look at the issue (and solr equivalent) :[Support Hierarchical Facets · Issue #1076 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1076)
> 
> 2011/12/30 project2501 [darreng5...@gmail.com](mailto:darreng5...@gmail.com)
> 
> > What do you define as a hierarchical facet?
> 
> > I implemented hierarchical faceting by providing a parent field in my  
> > query when faceting. It works.  
> > But relies that your hierarchy be established at index time through  
> > fields.
> 
> > On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > There is a plan to support it, nothing scheduled yet though (its tricky  
> > > to  
> > > make it performant).
> 
> > > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> 
> > > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > > 
> > > > ES has a ticket for this open on Github with lots of +1s.  
> > > > Solr has a few patches for this and Wiki page(s) describing how they  
> > > > work.
> 
> > > > Otis
> 
> > > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Hi there !
> 
> > > > > Is there any plan to implement hierarchical facets ?  
> > > > > If not we may help and contribute as we need this feature for a  
> > > > > starting  
> > > > > project  
> > > > > (this feature will determine if we choose elasticsearch over solr)
> 
> > > > > Cheers,
> 
> > > > > --  
> > > > > David Stendardi
> 
> --  
> David Stendardi

---

<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 30, 2011, 3:09pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/7 "2011-12-30T15:09:24Z")

</div>

What I like about this issue is the first comment which basically points to  
a new facet feature in Lucene without even understanding what it provides /  
how its implemented / or what its implications are :).

On Fri, Dec 30, 2011 at 4:19 PM, David Stendardi  
[david.stendardi@gmail.com](mailto:david.stendardi@gmail.com)wrote:

> take a look at the issue (and solr equivalent) :  
> [Support Hierarchical Facets · Issue #1076 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1076)
> 
> 2011/12/30 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)
> 
> > What do you define as a hierarchical facet?
> > 
> > I implemented hierarchical faceting by providing a parent field in my  
> > query when faceting. It works.  
> > But relies that your hierarchy be established at index time through  
> > fields.
> > 
> > On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > There is a plan to support it, nothing scheduled yet though (its tricky  
> > > to  
> > > make it performant).
> > > 
> > > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> > > 
> > > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > > 
> > > > ES has a ticket for this open on Github with lots of +1s.  
> > > > Solr has a few patches for this and Wiki page(s) describing how they  
> > > > work.
> > > 
> > > > Otis
> > > 
> > > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Hi there !
> > > 
> > > > > Is there any plan to implement hierarchical facets ?  
> > > > > If not we may help and contribute as we need this feature for a  
> > > > > starting  
> > > > > project  
> > > > > (this feature will determine if we choose elasticsearch over solr)
> > > 
> > > > > Cheers,
> > > 
> > > > > --  
> > > > > David Stendardi
> 
> --  
> David Stendardi

---

<div class="post-metadata">

**Author:** ![David\_Stendardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_stendardi/32/2990_2.png) [@David\_Stendardi](https://discuss.elastic.co/u/David_Stendardi)\
**Post date:** [December 30, 2011, 4:02pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/8 "2011-12-30T16:02:24Z")

</div>

I think we will use your solution, because when Shay says something is a  
bit tricky, it is a little scaring 🙂

2011/12/30 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)

> I achieved that using Solr out of the box using the technique I  
> mentioned above.  
> In my UI, when a user "drills" down from a facet in the hierarchy, it  
> issues another facet query on the fly. Works great.
> 
> On Dec 30, 9:19 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com) wrote:
> 
> > take a look at the issue (and solr equivalent) :  
> > [Support Hierarchical Facets · Issue #1076 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1076)
> > 
> > 2011/12/30 project2501 [darreng5...@gmail.com](mailto:darreng5...@gmail.com)
> > 
> > > What do you define as a hierarchical facet?
> > 
> > > I implemented hierarchical faceting by providing a parent field in my  
> > > query when faceting. It works.  
> > > But relies that your hierarchy be established at index time through  
> > > fields.
> > 
> > > On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > > 
> > > > There is a plan to support it, nothing scheduled yet though (its  
> > > > tricky  
> > > > to  
> > > > make it performant).
> > 
> > > > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> > 
> > > > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > > > 
> > > > > ES has a ticket for this open on Github with lots of +1s.  
> > > > > Solr has a few patches for this and Wiki page(s) describing how  
> > > > > they  
> > > > > work.
> > 
> > > > > Otis
> > 
> > > > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > Hi there !
> > 
> > > > > > Is there any plan to implement hierarchical facets ?  
> > > > > > If not we may help and contribute as we need this feature for a  
> > > > > > starting  
> > > > > > project  
> > > > > > (this feature will determine if we choose elasticsearch over  
> > > > > > solr)
> > 
> > > > > > Cheers,
> > 
> > > > > > --  
> > > > > > David Stendardi
> > 
> > --  
> > David Stendardi

--  
David Stendardi

---

<div class="post-metadata">

**Author:** ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)\
**Post date:** [December 30, 2011, 4:09pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/9 "2011-12-30T16:09:28Z")

</div>

Yeah, Occum's Razor wins in this case. What the issue is trying to  
suggest may require real magic.

My solution would work for ES too since its just vanilla lucene stuff.

On Dec 30, 10:09 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> What I like about this issue is the first comment which basically points to  
> a new facet feature in Lucene without even understanding what it provides /  
> how its implemented / or what its implications are :).
> 
> On Fri, Dec 30, 2011 at 4:19 PM, David Stendardi  
> [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)wrote:
> 
> > take a look at the issue (and solr equivalent) :  
> > [https://github.com/elasticsearch/elasticsearch/issues/1076](https://github.com/elasticsearch/elasticsearch/issues/1076)
> 
> > 2011/12/30 project2501 [darreng5...@gmail.com](mailto:darreng5...@gmail.com)
> 
> > > What do you define as a hierarchical facet?
> 
> > > I implemented hierarchical faceting by providing a parent field in my  
> > > query when faceting. It works.  
> > > But relies that your hierarchy be established at index time through  
> > > fields.
> 
> > > On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > > 
> > > > There is a plan to support it, nothing scheduled yet though (its tricky  
> > > > to  
> > > > make it performant).
> 
> > > > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> 
> > > > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > > > 
> > > > > ES has a ticket for this open on Github with lots of +1s.  
> > > > > Solr has a few patches for this and Wiki page(s) describing how they  
> > > > > work.
> 
> > > > > Otis
> 
> > > > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > Hi there !
> 
> > > > > > Is there any plan to implement hierarchical facets ?  
> > > > > > If not we may help and contribute as we need this feature for a  
> > > > > > starting  
> > > > > > project  
> > > > > > (this feature will determine if we choose elasticsearch over solr)
> 
> > > > > > Cheers,
> 
> > > > > > --  
> > > > > > David Stendardi
> 
> > --  
> > David Stendardi

---

<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 30, 2011, 4:21pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/10 "2011-12-30T16:21:49Z")

</div>

To be honest, the "tricky" part would be to build one that supports  
different "facets" for each hierarchy, i.e. break by terms and then break  
by range and then ..., while still having it performing decently. A  
specialized one, that just does two level terms is much simpler. At the end  
though, we might end up with several specialized ones since with  
specialized ones we can make them perform better.

On Fri, Dec 30, 2011 at 6:02 PM, David Stendardi  
[david.stendardi@gmail.com](mailto:david.stendardi@gmail.com)wrote:

> I think we will use your solution, because when Shay says something is a  
> bit tricky, it is a little scaring 🙂
> 
> 2011/12/30 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)
> 
> > I achieved that using Solr out of the box using the technique I  
> > mentioned above.  
> > In my UI, when a user "drills" down from a facet in the hierarchy, it  
> > issues another facet query on the fly. Works great.
> > 
> > On Dec 30, 9:19 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com) wrote:
> > 
> > > take a look at the issue (and solr equivalent) :  
> > > [Support Hierarchical Facets · Issue #1076 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1076)
> > > 
> > > 2011/12/30 project2501 [darreng5...@gmail.com](mailto:darreng5...@gmail.com)
> > > 
> > > > What do you define as a hierarchical facet?
> > > 
> > > > I implemented hierarchical faceting by providing a parent field in my  
> > > > query when faceting. It works.  
> > > > But relies that your hierarchy be established at index time through  
> > > > fields.
> > > 
> > > > On Dec 30, 7:35 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > > > 
> > > > > There is a plan to support it, nothing scheduled yet though (its  
> > > > > tricky  
> > > > > to  
> > > > > make it performant).
> > > 
> > > > > On Fri, Dec 30, 2011 at 10:01 AM, Otis Gospodnetic \<
> > > 
> > > > > [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com)\> wrote:
> > > > > 
> > > > > > ES has a ticket for this open on Github with lots of +1s.  
> > > > > > Solr has a few patches for this and Wiki page(s) describing how  
> > > > > > they  
> > > > > > work.
> > > 
> > > > > > Otis
> > > 
> > > > > > On Dec 29, 10:46 am, David Stendardi [david.stenda...@gmail.com](mailto:david.stenda...@gmail.com)  
> > > > > > wrote:
> > > > > > 
> > > > > > > Hi there !
> > > 
> > > > > > > Is there any plan to implement hierarchical facets ?  
> > > > > > > If not we may help and contribute as we need this feature for a  
> > > > > > > starting  
> > > > > > > project  
> > > > > > > (this feature will determine if we choose elasticsearch over  
> > > > > > > solr)
> > > 
> > > > > > > Cheers,
> > > 
> > > > > > > --  
> > > > > > > David Stendardi
> > > 
> > > --  
> > > David Stendardi
> 
> --  
> David Stendardi

---

<div class="post-metadata">

**Author:** ![Yeroc\_2](https://avatars.discourse-cdn.com/v4/letter/y/9de053/32.png) [@Yeroc\_2](https://discuss.elastic.co/u/Yeroc_2)\
**Post date:** [January 3, 2012, 4:36pm UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/11 "2012-01-03T16:36:47Z")

</div>

Have you ever had a change to talk to the LinkedIn guys or look at how Bobo  
([http://sna-projects.com/bobo/](http://sna-projects.com/bobo/)) is implemented? I looked at it some time  
ago and it seemed to work quite well... Not sure how it plays in a  
distributed world like ES but LinkedIn also had/have a working integration  
with Sensei (somewhat similar to ES) so there may well be some good things  
to learn there?

Regards,  
Corey

---

<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:43am UTC](https://discuss.elastic.co/t/hierarchical-facets/6252/12 "2017-07-06T03:43:58Z")

</div>


