# Must\_not query in nested doc not working

**URL:** <https://discuss.elastic.co/t/must-not-query-in-nested-doc-not-working/222024>\
**Category:** Elasticsearch\
**Created:** [March 4, 2020, 9:24am UTC](https://discuss.elastic.co/t/must-not-query-in-nested-doc-not-working/222024 "2020-03-04T09:24:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarungargbtp2612](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tarungargbtp2612/32/45903_2.png) [@tarungargbtp2612](https://discuss.elastic.co/u/tarungargbtp2612)\
**Post date:** [March 4, 2020, 9:24am UTC](https://discuss.elastic.co/t/must-not-query-in-nested-doc-not-working/222024/1 "2020-03-04T09:24:31Z")

</div>

I have written two queries the docs with field `profiles.educations = null`:

1. 

```auto
GET livecore/_search
{
  "query": {
    "nested": {
      "path": "profiles.educations",
      "query": {
        "bool": {
          "must_not": [
            {
              "exists": {
                "field": "profiles.educations"
              }
            }
          ]
        }
      }
    }
  }
}

```

1. 

```auto
GET livecore/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "nested": {
            "path": "profiles.educations",
            "query": {
              "exists": {
                "field": "profiles.educations"
              }
            }
          }
        }
      ]
    }
  }
}

```

The second query solves the purpose, but the first one not. Please help.

---

<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:** [April 1, 2020, 9:24am UTC](https://discuss.elastic.co/t/must-not-query-in-nested-doc-not-working/222024/2 "2020-04-01T09:24:35Z")

</div>

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