A term query treats the query as a single token. Because it does not apply any additional tokenization or processing to the query, it is useful when looking for exact matches.

The term query should not be confused with the match query, which auto-tokenizes the query string.

Basic Usage

Matches documents containing a specified term.

SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.term('description', 'shoes');
field
required

Specifies the field within the document to search for the term. If omitted, all indexed fields will be searched.

value
required

Value to search for in the document field.

Numeric, boolean, or datetime fields can also be passed into the term query.

SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.term('rating', 4);

Enumerated Types

term can be used to filter over custom Postgres enums if the query term is explicitly cast to the enum type. If JSON syntax is used, the underlying ordinal value of the enum must be used.

-- Assume we have indexed an enum called color
SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.term('color', 'red'::color);