1
votes

I found some description about must_not in the official document

must_not The clause (query) must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

It told me that the must_not will return a 0 score just like the filter operation. But when I execute this query:

GET /my_idx/my_type/_search
{
  "query": {
    "bool": {
      "must_not": [
        {"match" : {"name": "Test"}}
      ]
    }
  }
}

the response shows:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 6,
    "max_score": 1,
    "hits": [
      {
        "_index": "my_idx",
        "_type": "my_type",
        "_id": "Nbs5nmkBAfzcjFMf2czR",
        "_score": 1,
        "_source": {
          "analyzer": "my_tokenizer",
          "text": "Doe"
        }
      },
...

As you can see the "_score": 1

Why is this so?

1

1 Answers

0
votes

When you only have a must_not in the filter, an invisible match_all is present. What s why you got the _score = 1.