# When is fully qualified path to a nested doc field required?

**URL:** <https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407>\
**Category:** Elasticsearch\
**Created:** [January 24, 2014, 3:38pm UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407 "2014-01-24T15:38:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Treher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_treher/32/45243_2.png) [@Justin\_Treher](https://discuss.elastic.co/u/Justin_Treher)\
**Post date:** [January 24, 2014, 3:38pm UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407/1 "2014-01-24T15:38:41Z")

</div>

When exactly should you use the fully qualified path name in the case of  
standard objects, nested objects (documents), and combinations with  
multi\_field within?

I had an incident where my facets were not returning correctly. I traced it  
back to a nested facet filter and a field name inside that nested document  
that is used elsewhere in the document. When I reindexed, it "FIXED  
ITSELF." I thought, fine, I will fully qualify the path to prevent whatever  
issue just happened.

However, I also applied the fully qualified path to a multi\_field that is  
accessed via "just\_name" inside the nested document. In that case, I was  
not able to put the nested document path in front of it.

====Relevant chunk of mappings for this nested object=====  
{  
"categories": {  
"type": "nested",  
"properties": {  
"name": {  
"type": "multi\_field",  
"path": "just\_name",  
"fields": {  
"name": {  
"type": "string"  
},  
"name\_special": {  
"type": "string",  
}  
}  
},  
"default": {  
"type": "boolean" \<== this was my problem field, I use  
default in a non-nested object elsewhere in the document.  
}  
}  
}  
}

====facet=====  
{  
"facets": {  
"hierarchy": {  
"terms": {  
"field": "categories.name\_special" \<== doesn't work, have to  
use "name\_special" without path  
},  
"facet\_filter": {  
"term": {  
"categories.default": true \<== categories. prefix must be  
here to prevent another field in the "parent" doc from being used. Optional?  
}  
},  
"nested": "categories"  
}  
},  
"size": 0  
}

--  
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/2771c9b0-df08-4d9e-95c7-b3b2760fafb3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2771c9b0-df08-4d9e-95c7-b3b2760fafb3%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:** ![Justin\_Treher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_treher/32/45243_2.png) [@Justin\_Treher](https://discuss.elastic.co/u/Justin_Treher)\
**Post date:** [January 24, 2014, 5:04pm UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407/2 "2014-01-24T17:04:59Z")

</div>

As a follow-up, what is the default "path" applied to non-root objects?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Regarding the section "path?"

On Friday, January 24, 2014 10:38:41 AM UTC-5, Justin Treher wrote:

> When exactly should you use the fully qualified path name in the case of  
> standard objects, nested objects (documents), and combinations with  
> multi\_field within?
> 
> I had an incident where my facets were not returning correctly. I traced  
> it back to a nested facet filter and a field name inside that nested  
> document that is used elsewhere in the document. When I reindexed, it  
> "FIXED ITSELF." I thought, fine, I will fully qualify the path to prevent  
> whatever issue just happened.
> 
> However, I also applied the fully qualified path to a multi\_field that is  
> accessed via "just\_name" inside the nested document. In that case, I was  
> not able to put the nested document path in front of it.
> 
> ====Relevant chunk of mappings for this nested object=====  
> {  
> "categories": {  
> "type": "nested",  
> "properties": {  
> "name": {  
> "type": "multi\_field",  
> "path": "just\_name",  
> "fields": {  
> "name": {  
> "type": "string"  
> },  
> "name\_special": {  
> "type": "string",  
> }  
> }  
> },  
> "default": {  
> "type": "boolean" \<== this was my problem field, I use  
> default in a non-nested object elsewhere in the document.  
> }  
> }  
> }  
> }
> 
> ====facet=====  
> {  
> "facets": {  
> "hierarchy": {  
> "terms": {  
> "field": "categories.name\_special" \<== doesn't work, have to  
> use "name\_special" without path  
> },  
> "facet\_filter": {  
> "term": {  
> "categories.default": true \<== categories. prefix must be  
> here to prevent another field in the "parent" doc from being used. Optional?  
> }  
> },  
> "nested": "categories"  
> }  
> },  
> "size": 0  
> }

--  
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/658e5cc7-6df3-472a-b0bb-69b1f69342f0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/658e5cc7-6df3-472a-b0bb-69b1f69342f0%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:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [January 24, 2014, 5:06pm UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407/3 "2014-01-24T17:06:03Z")

</div>

Justin:

I think you probably meant to say:

{  
"facets": {  
"hierarchy": {  
"terms": {  
"field": "categories\*.name\*.name\_special"  
},  
"facet\_filter": {  
"term": {  
"categories.default": true  
}  
},  
"nested": "categories"  
}  
},  
"size": 0  
}

In general, when in doubt, always specify the full path in your queries.  
Please give it a try and let me know if that helps.

On Friday, January 24, 2014 10:38:41 AM UTC-5, Justin Treher wrote:

> When exactly should you use the fully qualified path name in the case of  
> standard objects, nested objects (documents), and combinations with  
> multi\_field within?
> 
> I had an incident where my facets were not returning correctly. I traced  
> it back to a nested facet filter and a field name inside that nested  
> document that is used elsewhere in the document. When I reindexed, it  
> "FIXED ITSELF." I thought, fine, I will fully qualify the path to prevent  
> whatever issue just happened.
> 
> However, I also applied the fully qualified path to a multi\_field that is  
> accessed via "just\_name" inside the nested document. In that case, I was  
> not able to put the nested document path in front of it.
> 
> ====Relevant chunk of mappings for this nested object=====  
> {  
> "categories": {  
> "type": "nested",  
> "properties": {  
> "name": {  
> "type": "multi\_field",  
> "path": "just\_name",  
> "fields": {  
> "name": {  
> "type": "string"  
> },  
> "name\_special": {  
> "type": "string",  
> }  
> }  
> },  
> "default": {  
> "type": "boolean" \<== this was my problem field, I use  
> default in a non-nested object elsewhere in the document.  
> }  
> }  
> }  
> }
> 
> ====facet=====  
> {  
> "facets": {  
> "hierarchy": {  
> "terms": {  
> "field": "categories.name\_special" \<== doesn't work, have to  
> use "name\_special" without path  
> },  
> "facet\_filter": {  
> "term": {  
> "categories.default": true \<== categories. prefix must be  
> here to prevent another field in the "parent" doc from being used. Optional?  
> }  
> },  
> "nested": "categories"  
> }  
> },  
> "size": 0  
> }

--  
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/80582230-ec20-46e3-99ed-e7b7cb1cf031%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/80582230-ec20-46e3-99ed-e7b7cb1cf031%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:** ![Justin\_Treher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_treher/32/45243_2.png) [@Justin\_Treher](https://discuss.elastic.co/u/Justin_Treher)\
**Post date:** [January 24, 2014, 5:13pm UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407/4 "2014-01-24T17:13:36Z")

</div>

Binh -

You are correct. The pathing with nested documents definitely confuses me!  
So, name.name\_special doesn't work. When I apply the path, it has to be the  
whole deal, categories.name.name\_special. So, the only issue I am left to  
resolve is that why on one version of my index is treating a  
non-root/non-nested object as "just\_name." I know I definitely did not  
change mappings.

But if I apply the "When in doubt, use the full path" rule, it would  
resolve itself anyhow I suppose, even if something screwing happened during  
the generation of the dynamic mappings..

Justin

On Friday, January 24, 2014 12:06:03 PM UTC-5, Binh Ly wrote:

> Justin:
> 
> I think you probably meant to say:
> 
> {  
> "facets": {  
> "hierarchy": {  
> "terms": {  
> "field": "categories\*.name\*.name\_special"  
> },  
> "facet\_filter": {  
> "term": {  
> "categories.default": true  
> }  
> },  
> "nested": "categories"  
> }  
> },  
> "size": 0  
> }
> 
> In general, when in doubt, always specify the full path in your queries.  
> Please give it a try and let me know if that helps.
> 
> On Friday, January 24, 2014 10:38:41 AM UTC-5, Justin Treher wrote:
> 
> > When exactly should you use the fully qualified path name in the case of  
> > standard objects, nested objects (documents), and combinations with  
> > multi\_field within?
> > 
> > I had an incident where my facets were not returning correctly. I traced  
> > it back to a nested facet filter and a field name inside that nested  
> > document that is used elsewhere in the document. When I reindexed, it  
> > "FIXED ITSELF." I thought, fine, I will fully qualify the path to prevent  
> > whatever issue just happened.
> > 
> > However, I also applied the fully qualified path to a multi\_field that is  
> > accessed via "just\_name" inside the nested document. In that case, I was  
> > not able to put the nested document path in front of it.
> > 
> > ====Relevant chunk of mappings for this nested object=====  
> > {  
> > "categories": {  
> > "type": "nested",  
> > "properties": {  
> > "name": {  
> > "type": "multi\_field",  
> > "path": "just\_name",  
> > "fields": {  
> > "name": {  
> > "type": "string"  
> > },  
> > "name\_special": {  
> > "type": "string",  
> > }  
> > }  
> > },  
> > "default": {  
> > "type": "boolean" \<== this was my problem field, I use  
> > default in a non-nested object elsewhere in the document.  
> > }  
> > }  
> > }  
> > }
> > 
> > ====facet=====  
> > {  
> > "facets": {  
> > "hierarchy": {  
> > "terms": {  
> > "field": "categories.name\_special" \<== doesn't work, have to  
> > use "name\_special" without path  
> > },  
> > "facet\_filter": {  
> > "term": {  
> > "categories.default": true \<== categories. prefix must be  
> > here to prevent another field in the "parent" doc from being used. Optional?  
> > }  
> > },  
> > "nested": "categories"  
> > }  
> > },  
> > "size": 0  
> > }

--  
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/8287ec2b-f983-48ae-b5ae-26a091cddfac%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8287ec2b-f983-48ae-b5ae-26a091cddfac%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:54am UTC](https://discuss.elastic.co/t/when-is-fully-qualified-path-to-a-nested-doc-field-required/15407/5 "2017-07-06T01:54:55Z")

</div>


