# Nested queries: when to provide path?

**URL:** <https://discuss.elastic.co/t/nested-queries-when-to-provide-path/21053>\
**Category:** Elasticsearch\
**Created:** [December 3, 2014, 9:28am UTC](https://discuss.elastic.co/t/nested-queries-when-to-provide-path/21053 "2014-12-03T09:28:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [December 3, 2014, 9:28am UTC](https://discuss.elastic.co/t/nested-queries-when-to-provide-path/21053/1 "2014-12-03T09:28:19Z")

</div>

Hi all,

With nested objects, I have noticed that sometimes you do not have to  
provide the path (ancestors).

For example,

A : {  
properties : {  
B : {  
type : "string"  
properties : {  
C : {  
type : "string"  
}  
}  
}  
}  
}

I have noticed in my documents, that sometimes I can just query C directly,  
e.g. ?q=C:blah.

However, sometimes I need to provide the whole path, e.g. ?q=A.B.C:blah.

Sometimes, I can provide a part of the path, e.g. ?q=B.C:blah.

Could someone explain what the logic is? Does it all depend on whether the  
deepest field has a unique name? Is there a "select all ancestors" function  
in ES like in XPath, i.e. //C?

Thanks!

/JZ

--  
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/157bce58-5736-4651-959c-7f8f03539e01%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/157bce58-5736-4651-959c-7f8f03539e01%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:46am UTC](https://discuss.elastic.co/t/nested-queries-when-to-provide-path/21053/2 "2017-07-06T00:46:23Z")

</div>


