Basic Usage

In addition to query strings, the @@@ operator also accepts JSONB query objects. These objects express nearly all of the query types available in Tantivy.

To use query objects, pass the key field to the left-hand side of the @@@ operator and Postgres JSONB to the right-hand side.

For instance, the following code block performs a fuzzy term search.

SELECT description, rating, category
FROM mock_items
WHERE id @@@ '{"fuzzy_term": {"field": "description", "value": "shoez"}}'::jsonb;

The query object must be explicitly cast to JSONB using ::jsonb.

JSON syntax queries can accept datetime values as strings. To disambiguate these from string values, you should set "is_datetime": true in the query parameters.

Unlike the query string syntax, the left-hand side takes a key field instead of column name because some query objects can span multiple columns.

Query Builder Functions

ParadeDB comes with query builder functions that make it easy to construct query objects without writing raw JSON. The following query is equivalent to the query written above:

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

All code blocks in this section provide both function and JSON syntax. These two syntaxes are interchangeable, giving you the freedom to decide what’s easier for your application to write.