> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paradedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exists

<Danger>
  **Legacy Docs:** This page describes our legacy API. It will be deprecated in
  a future version. Please use the [v2 API](/) where possible.
</Danger>

## Basic Usage

Matches all documents with a non-null value in the specified field. All matched documents get a BM25 score of `1.0`.

<Note>
  Will error if the field has not been indexed as a [fast
  field](/legacy/indexing/fast-fields).
</Note>

<CodeGroup>
  ```sql Function Syntax theme={null}
  SELECT description, rating, category
  FROM mock_items
  WHERE id @@@ paradedb.exists('rating')
  LIMIT 5;
  ```

  ```sql JSON Syntax theme={null}
  SELECT description, rating, category
  FROM mock_items
  WHERE id @@@
  '{
      "exists": {
          "field": "rating"
      }
  }'::jsonb
  LIMIT 5;
  ```
</CodeGroup>

<div className="mt-8" />

<ParamField body="field" required>
  Specifies the field within the document to search for the term.
</ParamField>

This query is useful for filtering on `NULL` values inside a [boolean query](/legacy/advanced/compound/boolean). For instance, the following code block
finds all rows with `description` matching `shoes` that have a non-null `rating`.

<CodeGroup>
  ```sql Function Syntax theme={null}
  SELECT description, rating, category
  FROM mock_items
  WHERE id @@@ paradedb.boolean(
    must => ARRAY[
      paradedb.term('description', 'shoes'),
      paradedb.exists('rating')
    ]
  )
  LIMIT 5;
  ```

  ```sql JSON Syntax theme={null}
  SELECT description, rating, category
  FROM mock_items
  WHERE id @@@
  '{
      "boolean": {
          "must": [
              {"term": {"field": "description", "value": "shoes"}},
              {"exists": {"field": "rating"}}
          ]
      }
  }'::jsonb
  LIMIT 5;
  ```
</CodeGroup>
