# ElasticSearch 2.x exists filter for nested field doesn't work

**URL:** <https://discuss.elastic.co/t/elasticsearch-2-x-exists-filter-for-nested-field-doesnt-work/65285>\
**Category:** Elasticsearch\
**Created:** [November 7, 2016, 10:33pm UTC](https://discuss.elastic.co/t/elasticsearch-2-x-exists-filter-for-nested-field-doesnt-work/65285 "2016-11-07T22:33:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pungent](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pungent](https://discuss.elastic.co/u/pungent)\
**Post date:** [November 7, 2016, 10:33pm UTC](https://discuss.elastic.co/t/elasticsearch-2-x-exists-filter-for-nested-field-doesnt-work/65285/1 "2016-11-07T22:33:14Z")

</div>

I have the following mapping

```
{
  "properties": {
    "restaurant_name": {"type": "string"},
    "menu": {
      "type": "nested",
      "properties": {
        "name": {"type": "string"}
      }
    }
  }
}

```

I am trying to filter all those documents which have optional "menu" field exists

```
GET /restaurnats/_search
{
  "filter": {
    "query": {
      "bool": {
        "must": [
          {"exists" : { "field" : "menu" }}
        ]
      }
    }
  }
}

```

But, when I try the same query to filter those documents which have "restaurant\_name", then it works fine. So why nested field check doesn't work? How to get it work?

---

<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:** [December 5, 2016, 10:33pm UTC](https://discuss.elastic.co/t/elasticsearch-2-x-exists-filter-for-nested-field-doesnt-work/65285/2 "2016-12-05T22:33:16Z")

</div>

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