NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Exists Query
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Exists Query
editReturns documents that contain a value other than null or [] in a provided
field.
Example request
editGET /_search
{
"query": {
"exists": {
"field": "user"
}
}
}
Top-level parameters for exists
edit-
field -
(Required, string) Name of the field you wish to search.
To return a document, this field must exist and contain a value other than
nullor[]. These values can include:-
Empty strings, such as
""or"-" -
Arrays containing
nulland another value, such as[null, "foo"] -
A custom
null-value, defined in field mapping
-
Empty strings, such as
Notes
editFind documents with null values
editTo find documents that contain only null values or [] in a provided field,
use the must_not boolean query with the exists
query.
The following search returns documents that contain only null values or []
in the user field.
GET /_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "user"
}
}
}
}
}