# Nested mappings with the same field names as the parent do not work

**URL:** <https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711>\
**Category:** Elasticsearch\
**Created:** [September 20, 2013, 10:24pm UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711 "2013-09-20T22:24:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthuhiggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthuhiggins/32/2091_2.png) [@matthuhiggins](https://discuss.elastic.co/u/matthuhiggins)\
**Post date:** [September 20, 2013, 10:24pm UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711/1 "2013-09-20T22:24:39Z")

</div>

If a nested mapping contains a field with the same name as the parent document, I am never able to retrieve any hits when searching for this field. Here is the simplest example:

> <https://gist.github.com/matthuhiggins/6644826>

---

<div class="post-metadata">

**Author:** ![matthuhiggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthuhiggins/32/2091_2.png) [@matthuhiggins](https://discuss.elastic.co/u/matthuhiggins)\
**Post date:** [September 20, 2013, 10:36pm UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711/2 "2013-09-20T22:36:08Z")

</div>

I added a gist for this: [nested mapping fields with the same name as the parent are not searchable · GitHub](https://gist.github.com/matthuhiggins/6644826)

On Friday, September 20, 2013 3:24:39 PM UTC-7, Matthew Higgins wrote:

> If a nested mapping contains a field with the same name as the parent  
> document, I am never able to retrieve any hits when searching for this  
> field. Here is the simplest example:
> 
> An article has a "title" field. Article has a nested mapping of comments,  
> which has the fields "author" and "title".
> 
> Now create one entry:
> 
> The following returns results:
> 
> The following does not return results, because the title field name is on  
> both "article" and "comment":
> 
> I think it's an edge case with nested mappings.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Nested-mappings-with-the-same-field-names-as-the-parent-do-not-work-tp4041645.html](http://elasticsearch-users.115913.n3.nabble.com/Nested-mappings-with-the-same-field-names-as-the-parent-do-not-work-tp4041645.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 21, 2013, 9:58am UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711/3 "2013-09-21T09:58:40Z")

</div>

The 'path' is not abbreviating the field name, but is a pointer to the  
nested object. Use 'comments.title' for field name.

See also  
[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)

Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![matthuhiggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthuhiggins/32/2091_2.png) [@matthuhiggins](https://discuss.elastic.co/u/matthuhiggins)\
**Post date:** [September 23, 2013, 5:00pm UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711/4 "2013-09-23T17:00:29Z")

</div>

Thanks! I was thrown off by the fact that an example without a prefix worked.

---

<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:15am UTC](https://discuss.elastic.co/t/nested-mappings-with-the-same-field-names-as-the-parent-do-not-work/13711/5 "2017-07-06T02:15:06Z")

</div>


