# Multi-level facet

**URL:** <https://discuss.elastic.co/t/multi-level-facet/4667>\
**Category:** Elasticsearch\
**Created:** [June 21, 2011, 5:47am UTC](https://discuss.elastic.co/t/multi-level-facet/4667 "2011-06-21T05:47:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [June 21, 2011, 5:47am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/1 "2011-06-21T05:47:25Z")

</div>

Hi,

I'm mostly working with Endeca related projects and I see  
ElasticSearch as an interesting open source project especially when  
dealing with massive data -- through auto-autosharding.

Endeca provides multi-level dimension/refinements. Is there a way to  
do the same in ElasticSearch? One major use of this feature is with  
multi-level categories.

Thanks in advance!

Raul

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [June 21, 2011, 6:31am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/2 "2011-06-21T06:31:40Z")

</div>

Hey Raul,  
Last I saw, not supported:  
[http://groups.google.com/a/elasticsearch.com/group/users/browse\_thread/thread/fb0a38ca19b02bde/b35d9531047278b6?lnk=gst&q=facet+hierarchical#b35d9531047278b6](http://groups.google.com/a/elasticsearch.com/group/users/browse_thread/thread/fb0a38ca19b02bde/b35d9531047278b6?lnk=gst&q=facet+hierarchical#b35d9531047278b6)

However, knowing Shay, it'll be there any day 🙂

Thanks,  
Paul

On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:

> Hi,
> 
> I'm mostly working with Endeca related projects and I see  
> Elasticsearch as an interesting open source project especially when  
> dealing with massive data -- through auto-autosharding.
> 
> Endeca provides multi-level dimension/refinements. Is there a way to  
> do the same in Elasticsearch? One major use of this feature is with  
> multi-level categories.
> 
> Thanks in advance!
> 
> Raul

---

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [June 21, 2011, 8:49am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/3 "2011-06-21T08:49:47Z")

</div>

Paul,

Thanks. Looking forward to this feature!

Thanks,  
Raul

On Jun 21, 2:31 pm, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:

> Hey Raul,  
> Last I saw, not supported:[http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> 
> However, knowing Shay, it'll be there any day 🙂
> 
> Thanks,  
> Paul
> 
> On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > Hi,
> 
> > I'm mostly working with Endeca related projects and I see  
> > Elasticsearch as an interesting open source project especially when  
> > dealing with massive data -- through auto-autosharding.
> 
> > Endeca provides multi-level dimension/refinements. Is there a way to  
> > do the same in Elasticsearch? One major use of this feature is with  
> > multi-level categories.
> 
> > Thanks in advance!
> 
> > Raul

---

<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:** [June 21, 2011, 8:55pm UTC](https://discuss.elastic.co/t/multi-level-facet/4667/4 "2011-06-21T20:55:05Z")

</div>

And if you want to port things from Solr before Shay gets to it, have  
a look at the Pivot stuff in Solr: [http://search-lucene.com/?q=pivot](http://search-lucene.com/?q=pivot)

Otis

On Jun 21, 2:31 am, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:

> Hey Raul,  
> Last I saw, not supported:[http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> 
> However, knowing Shay, it'll be there any day 🙂
> 
> Thanks,  
> Paul
> 
> On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > Hi,
> 
> > I'm mostly working with Endeca related projects and I see  
> > Elasticsearch as an interesting open source project especially when  
> > dealing with massive data -- through auto-autosharding.
> 
> > Endeca provides multi-level dimension/refinements. Is there a way to  
> > do the same in Elasticsearch? One major use of this feature is with  
> > multi-level categories.
> 
> > Thanks in advance!
> 
> > Raul

---

<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:** [June 29, 2011, 9:01pm UTC](https://discuss.elastic.co/t/multi-level-facet/4667/5 "2011-06-29T21:01:51Z")

</div>

Btw. I just created "Support Hierarchical Facets" at  
[https://github.com/elasticsearch/elasticsearch/issues/1076](https://github.com/elasticsearch/elasticsearch/issues/1076) .

I was going to suggest to vote for it if you are interested in having  
that, but I don't see a way to vote on issues on Github...

Otis

On Jun 21, 4:55 pm, Otis [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com) wrote:

> And if you want to port things from Solr before Shay gets to it, have  
> a look at thePivotstuff in Solr:[http://search-lucene.com/?q=pivot](http://search-lucene.com/?q=pivot)
> 
> Otis
> 
> On Jun 21, 2:31 am, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > Hey Raul,  
> > Last I saw, not supported:[http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> 
> > However, knowing Shay, it'll be there any day 🙂
> 
> > Thanks,  
> > Paul
> 
> > On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > > Hi,
> 
> > > I'm mostly working with Endeca related projects and I see  
> > > Elasticsearch as an interesting open source project especially when  
> > > dealing with massive data -- through auto-autosharding.
> 
> > > Endeca provides multi-level dimension/refinements. Is there a way to  
> > > do the same in Elasticsearch? One major use of this feature is with  
> > > multi-level categories.
> 
> > > Thanks in advance!
> 
> > > Raul

---

<div class="post-metadata">

**Author:** ![Hari\_Shankar](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@Hari\_Shankar](https://discuss.elastic.co/u/Hari_Shankar)\
**Post date:** [June 30, 2011, 4:43am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/6 "2011-06-30T04:43:40Z")

</div>

Great! This feature would be awesome..

On Thu, Jun 30, 2011 at 2:31 AM, Otis [otis.gospodnetic@gmail.com](mailto:otis.gospodnetic@gmail.com) wrote:

> Btw. I just created "Support Hierarchical Facets" at  
> [https://github.com/elasticsearch/elasticsearch/issues/1076](https://github.com/elasticsearch/elasticsearch/issues/1076) .
> 
> I was going to suggest to vote for it if you are interested in having  
> that, but I don't see a way to vote on issues on Github...
> 
> Otis
> 
> On Jun 21, 4:55 pm, Otis [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com) wrote:
> 
> > And if you want to port things from Solr before Shay gets to it, have  
> > a look at thePivotstuff in Solr:[http://search-lucene.com/?q=pivot](http://search-lucene.com/?q=pivot)
> > 
> > Otis
> > 
> > On Jun 21, 2:31 am, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > 
> > > Hey Raul,  
> > > Last I saw, not supported:  
> > > [http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> > 
> > > However, knowing Shay, it'll be there any day 🙂
> > 
> > > Thanks,  
> > > Paul
> > 
> > > On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> > 
> > > > Hi,
> > 
> > > > I'm mostly working with Endeca related projects and I see  
> > > > Elasticsearch as an interesting open source project especially when  
> > > > dealing with massive data -- through auto-autosharding.
> > 
> > > > Endeca provides multi-level dimension/refinements. Is there a way to  
> > > > do the same in Elasticsearch? One major use of this feature is with  
> > > > multi-level categories.
> > 
> > > > Thanks in advance!
> > 
> > > > Raul

---

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [July 19, 2011, 9:59am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/7 "2011-07-19T09:59:18Z")

</div>

Otis,  
Looks interesting. Is this code part of the recent release already?

> <https://github.com/elastic/elasticsearch/issues/1098>
>
> Support faceting on nested documents. It includes both faceting on child documen…ts matching a specific nested query (using scopes), and faceting on all nested documents of the matching root documents.
> 
> Why is it good for? First of all, this is the only way to use facets on nested documents once they are used (possibly for other reasons). But, there is also facet specific reason why nested documents can be used, and thats the fact that facets working on different key and value field (like \`term\_stats\`, or \`histogram\`) can now support cases where both are multi valued properly.
> 
> The following will use this same mapping:
> 
> \`\`\`
> {
> "type1" : {
> "properties" : {
> "obj1" : {
> "type" : "nested"
> }
> }
> }
> }
> \`\`\`
> 
> And, here is a sample data:
> 
> \`\`\`
> {
> "obj1" : \[
> {
> "name" : "blue",
> "count" : 4
> },
> {
> "name" : "green",
> "count" : 6
> }
> \]
> }
> \`\`\`
> \## Nested Query Facets
> 
> Any \`nested\` query allows to specify a \`\_scope\` associated with it. Any \`facet\` allows for a scope to be defined on it controlling the scope it will execute against. For example, the following \`facet1\` terms stats facet will only run on documents matching the nested query associated with \`my\_scope\`.
> 
> \`\`\`
> {
> "query" : {
> "nested" : {
> "\_scope" : "my\_scope"
> "path" : "obj1",
> "score\_mode" : "avg"
> "query" : {
> "bool" : {
> "must" : \[
> "text" : {"obj1.name" : "blue"},
> "range" : {"obj1.count" : {"gt" : 5}}
> \]
> }
> }
> }
> },
> "facets" : {
> "facet1" : {
> "terms\_stats" : {
> "key\_field" : "obj1.name",
> "value\_field" : "obj1.count",
> },
> "scope" : "my\_scope"
> }
> }
> }
> \`\`\`
> \## All Nested Matching Root Documents
> 
> Another option is to run the facet on all the nested documents matching the root objects that the main query will end up producing. For example:
> 
> \`\`\`
> {
> "query" : {
> "match\_all" : {}
> },
> "facets" : {
> "facet1" : {
> "terms\_stats" : {
> "key\_field" : "name",
> "value\_field" : "count",
> },
> "nested" : "obj1"
> }
> }
> }
> \`\`\`
> 
> The \`nested\` element provides the path to the nested document (can be a multi level nested docs) that will be used.

Looking forward on how to use it via Query DSL.

Regards,

Raul

On Jun 30, 5:01 am, Otis [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com) wrote:

> Btw. I just created "Support Hierarchical Facets" athttps://github.com/elasticsearch/elasticsearch/issues/1076.
> 
> I was going to suggest to vote for it if you are interested in having  
> that, but I don't see a way to vote on issues on Github...
> 
> Otis
> 
> On Jun 21, 4:55 pm, Otis [otis.gospodne...@gmail.com](mailto:otis.gospodne...@gmail.com) wrote:
> 
> > And if you want to port things from Solr before Shay gets to it, have  
> > a look at thePivotstuff in Solr:[http://search-lucene.com/?q=pivot](http://search-lucene.com/?q=pivot)
> 
> > Otis
> 
> > On Jun 21, 2:31 am, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > > Hey Raul,  
> > > Last I saw, not supported:[http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> 
> > > However, knowing Shay, it'll be there any day 🙂
> 
> > > Thanks,  
> > > Paul
> 
> > > On Jun 20, 11:47 pm, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > > > Hi,
> 
> > > > I'm mostly working with Endeca related projects and I see  
> > > > Elasticsearch as an interesting open source project especially when  
> > > > dealing with massive data -- through auto-autosharding.
> 
> > > > Endeca providesmulti-leveldimension/refinements. Is there a way to  
> > > > do the same in Elasticsearch? One major use of this feature is with  
> > > > multi-levelcategories.
> 
> > > > Thanks in advance!
> 
> > > > Raul

---

<div class="post-metadata">

**Author:** ![phobos182](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phobos182/32/3011_2.png) [@phobos182](https://discuss.elastic.co/u/phobos182)\
**Post date:** [July 25, 2011, 1:07pm UTC](https://discuss.elastic.co/t/multi-level-facet/4667/8 "2011-07-25T13:07:30Z")

</div>

This would be a huge gain for us. +1

---

<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:59am UTC](https://discuss.elastic.co/t/multi-level-facet/4667/9 "2017-07-06T03:59:34Z")

</div>


