Elasticsearch must_not bool query is not working

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

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

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