# Nested type and range facet

**URL:** <https://discuss.elastic.co/t/nested-type-and-range-facet/5060>\
**Category:** Elasticsearch\
**Created:** [August 5, 2011, 3:43am UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060 "2011-08-05T03:43:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Everton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_everton/32/1865_2.png) [@Dan\_Everton](https://discuss.elastic.co/u/Dan_Everton)\
**Post date:** [August 5, 2011, 3:43am UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060/1 "2011-08-05T03:43:43Z")

</div>

Howdy,

I'm trying to do a query with a range facet that has the key field come from  
the parent document and the value field values come from all nested  
documents. Here's a gist of the idea

> <https://gist.github.com/deverton/1126866>

What I'm hoping for is to have each rating range facet have the min, max,  
average, etc of the prices within the nested document of the matching  
containing document.

Now that I look at it again at the nested facet documentation, I'm thinking  
this isn't possible, but I'd loved to be proved wrong.

Cheers,  
Dan

---

<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:** [August 5, 2011, 7:46pm UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060/2 "2011-08-05T19:46:02Z")

</div>

This is not possible, but, what you can do is set include\_in\_parent on the  
nested mapping, which will cause the values to also be indexed in the parent  
doc. The range facet supports cases with single key multiple values per doc.

On Fri, Aug 5, 2011 at 6:43 AM, Dan Everton [dan@iocaine.org](mailto:dan@iocaine.org) wrote:

> Howdy,
> 
> I'm trying to do a query with a range facet that has the key field come  
> from the parent document and the value field values come from all nested  
> documents. Here's a gist of the idea
> 
> [Faceting by both document and nested document · GitHub](https://gist.github.com/1126866)
> 
> What I'm hoping for is to have each rating range facet have the min, max,  
> average, etc of the prices within the nested document of the matching  
> containing document.
> 
> Now that I look at it again at the nested facet documentation, I'm thinking  
> this isn't possible, but I'd loved to be proved wrong.
> 
> Cheers,  
> Dan

---

<div class="post-metadata">

**Author:** ![Dan\_Everton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_everton/32/1865_2.png) [@Dan\_Everton](https://discuss.elastic.co/u/Dan_Everton)\
**Post date:** [August 7, 2011, 10:47pm UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060/3 "2011-08-07T22:47:43Z")

</div>

Okay, yeah, that makes sense. Kind of blows out the index size a bit, but it  
works.

---

<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:** [August 8, 2011, 7:37am UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060/4 "2011-08-08T07:37:08Z")

</div>

In theory, we can support this case for facets, though with a lot of more  
coding... . Open an issue for this so we won't forget.

On Mon, Aug 8, 2011 at 1:47 AM, Dan Everton [dan@iocaine.org](mailto:dan@iocaine.org) wrote:

> Okay, yeah, that makes sense. Kind of blows out the index size a bit, but  
> it works.

---

<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:57am UTC](https://discuss.elastic.co/t/nested-type-and-range-facet/5060/5 "2017-07-06T03:57:59Z")

</div>


