# Elasticsearch must\_not bool query is not working

**URL:** <https://discuss.elastic.co/t/elasticsearch-must-not-bool-query-is-not-working/127397>\
**Category:** Elasticsearch\
**Created:** [April 9, 2018, 10:49pm UTC](https://discuss.elastic.co/t/elasticsearch-must-not-bool-query-is-not-working/127397 "2018-04-09T22:49:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adf4st](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@adf4st](https://discuss.elastic.co/u/adf4st)\
**Post date:** [April 9, 2018, 10:49pm UTC](https://discuss.elastic.co/t/elasticsearch-must-not-bool-query-is-not-working/127397/1 "2018-04-09T22:49:56Z")

</div>

I have a bool query with a filter and a must\_not clause. But when I execute the query I get results that contain the values specified in the must\_not clause. Any idea what I'm doing wrong?

**Query**

```
POST /test/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "partnerId": {
              "value": 12345
            }
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "stage": {
              "value": "REJECTED"
            }
          }
        }
      ],
      "adjust_pure_negative": true
    }
  }
}

```

**Response**

```
{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0,
    "hits": [
      {
        "_index": "test",
        "_type": "doc",
        "_id": "45678910",
        "_score": 0,
        "_source": {
          "id": 45678910,
          "partnerId": 12345,
          "stage": "REJECTED"
        }
      }
    ]
  }
}

```

Notice how in my results I'm still getting a REJECTED stage even though I've included that in the must\_not clause.

Elasticsearch version : 6.2.2

---

<div class="post-metadata">

**Author:** ![Giovanni\_Caputo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giovanni_caputo/32/10580_2.png) [@Giovanni\_Caputo](https://discuss.elastic.co/u/Giovanni_Caputo)\
**Post date:** [April 10, 2018, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-must-not-bool-query-is-not-working/127397/2 "2018-04-10T07:27:18Z")

</div>

> [@adf4st](#):
>
> REJECTED

what analyze use for stage field? show us mapping...

---

<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 8, 2018, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-must-not-bool-query-is-not-working/127397/3 "2018-05-08T07:27:28Z")

</div>

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