Exists Filteredit

Returns documents that have at least one non-null value in the original field:

{
    "constant_score" : {
        "filter" : {
            "exists" : { "field" : "user" }
        }
    }
}

For instance, these documents would all match the above filter:

{ "user": "jane" }
{ "user": "" } 
{ "user": "-" } 
{ "user": ["jane"] }
{ "user": ["jane", null ] } 

An empty string is a non-null value.

Even though the standard analyzer would emit zero tokens, the original field is non-null.

At least one non-null value is required.

These documents would not match the above filter:

{ "user": null }
{ "user": [] } 
{ "user": [null] } 
{ "foo":  "bar" } 

This field has no values.

At least one non-null value is required.

The user field is missing completely.

null_value mappingedit

If the field mapping includes the null_value setting (see Core Types) then explicit null values are replaced with the specified null_value. For instance, if the user field were mapped as follows:

  "user": {
    "type": "string",
    "null_value": "_null_"
  }

then explicit null values would be indexed as the string _null_, and the following docs would match the exists filter:

{ "user": null }
{ "user": [null] }

However, these docs—without explicit null values—would still have no values in the user field and thus would not match the exists filter:

{ "user": [] }
{ "foo": "bar" }

Cachingedit

The result of the filter is always cached.