# Nested fields with identical key names query discrepancy

**URL:** <https://discuss.elastic.co/t/nested-fields-with-identical-key-names-query-discrepancy/27520>\
**Category:** Elasticsearch\
**Created:** [August 17, 2015, 3:55pm UTC](https://discuss.elastic.co/t/nested-fields-with-identical-key-names-query-discrepancy/27520 "2015-08-17T15:55:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Steinmetz](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jeff\_Steinmetz](https://discuss.elastic.co/u/Jeff_Steinmetz)\
**Post date:** [August 17, 2015, 3:55pm UTC](https://discuss.elastic.co/t/nested-fields-with-identical-key-names-query-discrepancy/27520/1 "2015-08-17T15:55:04Z")

</div>

This was discussed in the Kibana thread here, and the suggested was made to post in in this discussion group.

> <https://github.com/elastic/kibana/issues/4679>

Review the thread discussion for more details.

I've posted a vagrant file that helps reproduce the scenario. Boots up a default 1.7.1 elasticsearch install. (to spin it up, use vagrant, virtual box and ansible).

clone or download zip from here, view README.md for instructions:

> **[jeffsteinmetz/kibana-issue-4679](https://github.com/jeffsteinmetz/kibana-issue-4679)**
>
> Contribute to kibana-issue-4679 development by creating an account on GitHub.

It demonstrates that this returns no hits (expected 1 hit)

```auto
GET /test17/_search
{
    "query": {
        "filtered": {
            "query": {
                "query_string": {
                    "query": "user.id:\"84ba51f5-4939-4639-a15f-9cb9d793fea2\""
                }
            }
        }
    }
}

```

and this returns 1 hit

```auto
GET /test17/user/_search
{
    "query": {
        "filtered": {
            "query": {
                "query_string": {
                    "query": "user.id:\"84ba51f5-4939-4639-a15f-9cb9d793fea2\""
                }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 18, 2015, 10:11am UTC](https://discuss.elastic.co/t/nested-fields-with-identical-key-names-query-discrepancy/27520/2 "2015-08-18T10:11:47Z")

</div>

You could have fallen victim to the 'Ambiguous Field Lookup' problem described here: [https://www.elastic.co/blog/great-mapping-refactoring#ambiguous-fields](https://www.elastic.co/blog/great-mapping-refactoring#ambiguous-fields). In 2.0 the mappings have been refactored to prevent this.

---

<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 5, 2017, 11:55pm UTC](https://discuss.elastic.co/t/nested-fields-with-identical-key-names-query-discrepancy/27520/3 "2017-07-05T23:55:22Z")

</div>


