# Problem with faceted query on nested objects showing all terms "missing"

**URL:** https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178
**Category:** Elasticsearch
**Created:** [August 17, 2011, 1:52am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178 "2011-08-17T01:52:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Daniel\_E](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_e/32/3137_2.png) [@Daniel\_E](https://discuss.elastic.co/u/Daniel_E)
#### Post date: [August 17, 2011, 1:52am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/1 "2011-08-17T01:52:28Z")

</div>

Here is a screenshot of a query and the results I'm seeing:

> **[2011-08-16\_1839](http://www.screencast.com/t/TsgnJUQuVm)**
>
> Shared from Screencast.com

It is exceptionally frustrating because it worked for one of the  
values once, but not the other. I restarted ES to see if it was a  
glitch, then it was not working for either. No config changes,  
nothing other than a shutdown and restart of ES.

I created the following mapping template and validated that every  
wildcarded entry properly shows as type: nested and include\_in\_root:

curl -XPUT '[http://localhost:9200/telemetry-test/data/\_mapping](http://localhost:9200/telemetry-test/data/_mapping)' -d '  
{  
"data" : {  
"dynamic\_templates" : [  
{  
"values\_template": {  
"path\_match": "histograms.\*.values",  
"mapping": {  
"include\_in\_root": true,  
"type": "nested"  
}  
}  
}  
]  
}  
}  
'

---

<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 17, 2011, 1:55am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/2 "2011-08-17T01:55:04Z")

</div>

Daniel, try and use the full nested path for the fields you specify in the  
facets. Note, if you specify include\_in\_parent, those facets will require  
considerable amount of extra memory, so, try and see if you really need  
it...

On Wed, Aug 17, 2011 at 4:52 AM, Daniel E [deinspanjer@gmail.com](mailto:deinspanjer@gmail.com) wrote:

> Here is a screenshot of a query and the results I'm seeing:  
> [http://screencast.com/t/TsgnJUQuVm](http://screencast.com/t/TsgnJUQuVm)
> 
> It is exceptionally frustrating because it worked for one of the  
> values once, but not the other. I restarted ES to see if it was a  
> glitch, then it was not working for either. No config changes,  
> nothing other than a shutdown and restart of ES.
> 
> I created the following mapping template and validated that every  
> wildcarded entry properly shows as type: nested and include\_in\_root:
> 
> curl -XPUT '[http://localhost:9200/telemetry-test/data/\_mapping](http://localhost:9200/telemetry-test/data/_mapping)' -d '  
> {  
> "data" : {  
> "dynamic\_templates" : [  
> {  
> "values\_template": {  
> "path\_match": "histograms.\*.values",  
> "mapping": {  
> "include\_in\_root": true,  
> "type": "nested"  
> }  
> }  
> }  
> ]  
> }  
> }  
> '

---

<div class="post-metadata">

### Author: ![Daniel\_E](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_e/32/3137_2.png) [@Daniel\_E](https://discuss.elastic.co/u/Daniel_E)
#### Post date: [August 17, 2011, 1:59am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/3 "2011-08-17T01:59:23Z")

</div>

Yes. I was not specifying the full path for key\_field and  
value\_field. That made it work.

Now that I have at least one working case, I'll go back and try again  
without include\_in\_parent. that was just a wild stab at getting it to  
work.

Question regarding performance (assuming that they are _not_ included  
in parent/root):  
If I have hundreds of thousands or even millions of root documents,  
and dozens of this histogram objects, each with tens of nested  
"values" objects, I will end up with a technical document count in the  
billions because nested objects are indexed as extra documents. Will  
I suffer in terms of scale in this case or are these nested object  
documents efficient enough that I don't have to worry about having  
billions when I only have hundreds of thousands of parent docs?

On Aug 16, 6:55 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Daniel, try and use the full nested path for the fields you specify in the  
> facets. Note, if you specify include\_in\_parent, those facets will require  
> considerable amount of extra memory, so, try and see if you really need  
> it...
> 
> On Wed, Aug 17, 2011 at 4:52 AM, Daniel E [deinspan...@gmail.com](mailto:deinspan...@gmail.com) wrote:
> 
> > Here is a screenshot of a query and the results I'm seeing:  
> > [http://screencast.com/t/TsgnJUQuVm](http://screencast.com/t/TsgnJUQuVm)
> 
> > It is exceptionally frustrating because it worked for one of the  
> > values once, but not the other. I restarted ES to see if it was a  
> > glitch, then it was not working for either. No config changes,  
> > nothing other than a shutdown and restart of ES.
> 
> > I created the following mapping template and validated that every  
> > wildcarded entry properly shows as type: nested and include\_in\_root:
> 
> > curl -XPUT '[http://localhost:9200/telemetry-test/data/\_mapping'-d](http://localhost:9200/telemetry-test/data/_mapping'-d) '  
> > {  
> > "data" : {  
> > "dynamic\_templates" : [  
> > {  
> > "values\_template": {  
> > "path\_match": "histograms.\*.values",  
> > "mapping": {  
> > "include\_in\_root": true,  
> > "type": "nested"  
> > }  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > '

---

<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 17, 2011, 2:01am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/4 "2011-08-17T02:01:53Z")

</div>

Well, you will need to test it out 🙂 (and scale if perf is not good  
enough). In general, those facet values are loaded to memory, and  
computation is pretty fast, so, we make a lot of effort to make it as fast  
as possible...

On Wed, Aug 17, 2011 at 4:59 AM, Daniel E [deinspanjer@gmail.com](mailto:deinspanjer@gmail.com) wrote:

> Yes. I was not specifying the full path for key\_field and  
> value\_field. That made it work.
> 
> Now that I have at least one working case, I'll go back and try again  
> without include\_in\_parent. that was just a wild stab at getting it to  
> work.
> 
> Question regarding performance (assuming that they are _not_ included  
> in parent/root):  
> If I have hundreds of thousands or even millions of root documents,  
> and dozens of this histogram objects, each with tens of nested  
> "values" objects, I will end up with a technical document count in the  
> billions because nested objects are indexed as extra documents. Will  
> I suffer in terms of scale in this case or are these nested object  
> documents efficient enough that I don't have to worry about having  
> billions when I only have hundreds of thousands of parent docs?
> 
> On Aug 16, 6:55 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Daniel, try and use the full nested path for the fields you specify in  
> > the  
> > facets. Note, if you specify include\_in\_parent, those facets will require  
> > considerable amount of extra memory, so, try and see if you really need  
> > it...
> > 
> > On Wed, Aug 17, 2011 at 4:52 AM, Daniel E [deinspan...@gmail.com](mailto:deinspan...@gmail.com) wrote:
> > 
> > > Here is a screenshot of a query and the results I'm seeing:  
> > > [http://screencast.com/t/TsgnJUQuVm](http://screencast.com/t/TsgnJUQuVm)
> > 
> > > It is exceptionally frustrating because it worked for one of the  
> > > values once, but not the other. I restarted ES to see if it was a  
> > > glitch, then it was not working for either. No config changes,  
> > > nothing other than a shutdown and restart of ES.
> > 
> > > I created the following mapping template and validated that every  
> > > wildcarded entry properly shows as type: nested and include\_in\_root:
> > 
> > > curl -XPUT '[http://localhost:9200/telemetry-test/data/\_mapping'-d](http://localhost:9200/telemetry-test/data/_mapping'-d) '  
> > > {  
> > > "data" : {  
> > > "dynamic\_templates" : [  
> > > {  
> > > "values\_template": {  
> > > "path\_match": "histograms.\*.values",  
> > > "mapping": {  
> > > "include\_in\_root": true,  
> > > "type": "nested"  
> > > }  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > '

---

<div class="post-metadata">

### Author: ![Daniel\_E](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_e/32/3137_2.png) [@Daniel\_E](https://discuss.elastic.co/u/Daniel_E)
#### Post date: [August 17, 2011, 2:46am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/5 "2011-08-17T02:46:22Z")

</div>

Will definitely be testing it. Just a bit scary to go from 1 million docs to 5 billion just by setting type:nested. 🙂

---

<div class="post-metadata">

### Author: ![revdev](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@revdev](https://discuss.elastic.co/u/revdev)
#### Post date: [January 2, 2013, 6:49pm UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/6 "2013-01-02T18:49:12Z")

</div>

Daniel,  
I am facing a similar situation. I am wondering if you learned something  
from your experience. If you can share any interesting bits found, then it  
would really help. thanks!  
Vinay

On Tuesday, August 16, 2011 7:46:22 PM UTC-7, Daniel E wrote:

> Will definitely be testing it. Just a bit scary to go from 1 million docs  
> to 5 billion just by setting type:nested. 🙂

--

---

<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, 2:58am UTC](https://discuss.elastic.co/t/problem-with-faceted-query-on-nested-objects-showing-all-terms-missing/5178/7 "2017-07-06T02:58:01Z")

</div>


