# N-th order nesting where n\>=3

**URL:** <https://discuss.elastic.co/t/n-th-order-nesting-where-n-3/15563>\
**Category:** Elasticsearch\
**Created:** [February 3, 2014, 6:04pm UTC](https://discuss.elastic.co/t/n-th-order-nesting-where-n-3/15563 "2014-02-03T18:04:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Ohno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_ohno/32/1746_2.png) [@John\_Ohno](https://discuss.elastic.co/u/John_Ohno)\
**Post date:** [February 3, 2014, 6:04pm UTC](https://discuss.elastic.co/t/n-th-order-nesting-where-n-3/15563/1 "2014-02-03T18:04:15Z")

</div>

Hi,  
I have a mapping that looks a bit like this:

{ "foo" : {  
"type" : "nested",  
"properties" : {  
"bar" : {  
"type" : "nested",  
"properties" : {  
"baz" : {  
"type" : "nested",  
"properties" : {  
"quux" : { "type" : "string" }  
}  
}  
}  
}  
}  
}  
}

I want to perform a search that distinguishes between instances at the very  
deepest levels of this hierarchy (i.e.: a foo can contain many bars which  
contain many bazzes which contain many quuxen, but I wish to distinguish  
between quux="hello" in the same baz as quux="goodbye" and quux="hello" in  
the same bar as quux="goodbye").

A query like this gives me zero results, even when I _know_ that it's  
correctly formed:  
{ "nested" : {  
"path" : "foo",  
"query" : {  
"nested" : {  
"path" : "bar",  
"query" : {  
"nested" : {  
"path" : "baz",  
"query" : {  
"bool" : {  
"must" : [  
{ "term" : { "foo.bar.baz.quux" : "hello"} } ,  
{ "term" : { "foo.bar.baz.quux" : "goodbye" } }  
]  
}  
}  
}  
}  
}  
}  
}}

If I specify intermediate paths in fully qualified terms (for instance,  
{"nested": { "path" : "foo.bar.baz"}}), I get an error message claiming  
that my fully qualified intermediate path does not refer to a nested object.

Everything I've seen on the web has referred to trivial 1- or 2-level  
nesting. Is there some stupid conceptual mistake I'm making here?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/37490f04-8331-432b-9776-dbfab97116db%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/37490f04-8331-432b-9776-dbfab97116db%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:53am UTC](https://discuss.elastic.co/t/n-th-order-nesting-where-n-3/15563/2 "2017-07-06T01:53:05Z")

</div>

Closed on July 6, 2017, 1:53am UTC


