# Term query on nested field returns empty result, why?

**URL:** <https://discuss.elastic.co/t/term-query-on-nested-field-returns-empty-result-why/194642>\
**Category:** Elasticsearch\
**Created:** [August 9, 2019, 3:16pm UTC](https://discuss.elastic.co/t/term-query-on-nested-field-returns-empty-result-why/194642 "2019-08-09T15:16:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas-gruenwald](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@andreas-gruenwald](https://discuss.elastic.co/u/andreas-gruenwald)\
**Post date:** [August 9, 2019, 3:16pm UTC](https://discuss.elastic.co/t/term-query-on-nested-field-returns-empty-result-why/194642/1 "2019-08-09T15:16:34Z")

</div>

```auto
GET /at_de_elastic/_search
{
  "_source": [
    "attributes.articleName",
    "attributes.remoteId",
    "attributes.comparisonListMetadataSearch"
  ],
    "query": {
        "term": {
            "attributes.remoteId": {
                "value": "00770013",
                "boost": 1.0
            }
        }
    }
}

```

returns

```auto
{
  "hits" : {
    "total" : 1,
    "max_score" : 9.504323,
    "hits" : [
      {
        "_index" : "at_de_elastic-27",
        "_type" : "Product",
        "_id" : "3247218",
        "_score" : 9.504323,
        "_routing" : "3247218",
        "_source" : {
          "attributes" : {
            "articleName" : "Vergaser-Reparatursatz RK-23HS anstelle von Tillotson",
            "comparisonListMetadataSearch" : [
              {
                "number" : "4153020",
                "name" : "Alpina",
                "normalizedNumber" : "4153020"
              }
            ],
            "remoteId" : "00770013"
          }
        }
      }
    ]
  }
}

```

Why does

```auto
GET /at_de_elastic/_search
{
    "query": {
        "term": {
            "attributes.comparisonListMetadataSearch.number": {
                "value": "4153020"
            }
        }
    }
}

```

return an empty result?

This is the relevant part of the mapping:

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/6/f6c6b905625dbe884a54236f71e428dfd31fee73.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f4dee2b81145c017936ffda927c14c4736337ef3.png)

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 12, 2019, 8:13am UTC](https://discuss.elastic.co/t/term-query-on-nested-field-returns-empty-result-why/194642/2 "2019-08-12T08:13:32Z")

</div>

the field `comparisonListMetadataSearch` is configured is `nested` and thus also needs to be wrapped into a [nested query](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl-nested-query.html), the `remoteId` is not (at least it is not listed).

---

<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:** [September 9, 2019, 8:13am UTC](https://discuss.elastic.co/t/term-query-on-nested-field-returns-empty-result-why/194642/3 "2019-09-09T08:13:33Z")

</div>

Closed on September 9, 2019, 8:13am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
