elasticsearch/docs/reference/query-languages/query-dsl-exists-query.md
Colleen McGinnis b7e3a1e14b
[docs] Migrate docs from AsciiDoc to Markdown (#123507)
* delete asciidoc files

* add migrated files

* fix errors

* Disable docs tests

* Clarify release notes page titles

* Revert "Clarify release notes page titles"

This reverts commit 8be688648d.

* Comment out edternal URI images

* Clean up query languages landing pages, link to conceptual docs

* Add .md to url

* Fixes inference processor nesting.

---------

Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com>
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
Co-authored-by: István Zoltán Szabó <szabosteve@gmail.com>
2025-02-27 17:56:14 +01:00

1.8 KiB
Raw Blame History

navigation_title mapped_pages
Exists
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

Exists query [query-dsl-exists-query]

Returns documents that contain an indexed value for a field.

An indexed value may not exist for a documents field due to a variety of reasons:

  • The field in the source JSON is null or []
  • The field has "index" : false and "doc_values" : false set in the mapping
  • The length of the field value exceeded an ignore_above setting in the mapping
  • The field value was malformed and ignore_malformed was defined in the mapping

Example request [exists-query-ex-request]

GET /_search
{
  "query": {
    "exists": {
      "field": "user"
    }
  }
}

Top-level parameters for exists [exists-query-top-level-params]

field
(Required, string) Name of the field you wish to search.

While a field is deemed non-existent if the JSON value is null or [], these values will indicate the field does exist:

  • Empty strings, such as "" or "-"
  • Arrays containing null and another value, such as [null, "foo"]
  • A custom null-value, defined in field mapping

Notes [exists-query-notes]

Find documents missing indexed values [find-docs-null-values]

To find documents that are missing an indexed value for a field, use the must_not boolean query with the exists query.

The following search returns documents that are missing an indexed value for the user.id field.

GET /_search
{
  "query": {
    "bool": {
      "must_not": {
        "exists": {
          "field": "user.id"
        }
      }
    }
  }
}