---
title: Exists
---

## 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](/documentation/indexing/fast_fields).
</Note>

<CodeGroup>
```sql Function Syntax
SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.exists('rating')
LIMIT 5;
```
```sql JSON Syntax
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](/documentation/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
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
SELECT description, rating, category
FROM mock_items
WHERE id @@@
'{
    "boolean": {
        "must": [
            {"term": {"field": "description", "value": "shoes"}},
            {"exists": {"field": "rating"}}
        ]
    }
}'::jsonb
LIMIT 5;
```
</CodeGroup>
