# MUST\_NOT and EXIST in NESTED query

**URL:** <https://discuss.elastic.co/t/must-not-and-exist-in-nested-query/176505>\
**Category:** Elasticsearch\
**Created:** [April 11, 2019, 9:35pm UTC](https://discuss.elastic.co/t/must-not-and-exist-in-nested-query/176505 "2019-04-11T21:35:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikael](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikael](https://discuss.elastic.co/u/mikael)\
**Post date:** [April 11, 2019, 9:35pm UTC](https://discuss.elastic.co/t/must-not-and-exist-in-nested-query/176505/1 "2019-04-11T21:35:47Z")

</div>

I use es 6.5.1 and have the same problem like:

> [@MUST\_NOT not working with EXIST in NESTED query](https://discuss.elastic.co/t/must-not-not-working-with-exist-in-nested-query/101952):
>
> ES 5.2.2 Here is my mapping: PUT players { "mappings": { "players": { "properties": { "features": { "type": "nested", "properties": { "name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore\_above": 256 } } }, …

Copy from the topic above.

```auto
PUT players
{
   "mappings": {
      "players": {
         "properties": {
            "features": {
               "type": "nested",
               "properties": {
                  "name": {
                     "type": "text",
                     "fields": {
                        "keyword": {
                           "type": "keyword",
                           "ignore_above": 256
                        }
                     }
                  },
                  "value": {
                     "type": "long"
                  }
               }
            },
            "name": {
               "type": "text",
               "fields": {
                  "keyword": {
                     "type": "keyword",
                     "ignore_above": 256
                  }
               }
            }
         }
      }
   }
}

```

I would like to find doc where 'features' does not has any child.

But solution presented in link not work for my.  
Suggested solution:

```auto
POST players/players/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "nested": {
            "path": "features",
            "query": {
              "exists": {
                "field": "features"
              }
            }
          }
        }
      ]
    }
  }
}

```

---

<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:** [May 9, 2019, 9:35pm UTC](https://discuss.elastic.co/t/must-not-and-exist-in-nested-query/176505/2 "2019-05-09T21:35:54Z")

</div>

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