Skip to content

exists query returns no documents for a no-value constant_keyword #53545

@astefan

Description

@astefan

Considering the following mapping

{
  "mappings": {
    "properties": {
      "cycle_type": {
        "type": "constant_keyword"
      },
      "name": {
        "type": "text"
      }
    }
  }
}

And the following bulk of documents:

{"index":{"_id":1}}
{"name":"kawasaki"}
{"index":{"_id":2}}
{"name":"1938"}
{"index":{"_id":3}}
{"name":"1924"}

there won't be any value associated with cycle_type field. But, running the following query has some unexpected results:

{
    "query": {
        "bool": {
            "must_not": [
                {
                    "exists": {
                        "field": "cycle_type"
                    }
                }
            ]
        }
    }
}

There won't be any documents returned, whereas it should return all of them because cycle_type doesn't have a value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions