In addition to query strings, JSONB query objects and query builder functions can be used to compose various types of more complex queries.

If you are familiar with Elasticsearch’s API, you may notice that the available query types are similar to those found in Elastic’s query DSL. This is intentional — ParadeDB uses the same terminology as Elasticsearch for its query types.

Basic Usage

The left-hand side of @@@ must be the key field and the right-hand side should be either a JSON object or query builder function. For instance, the following code block executes a match query.

SELECT description, rating, category
FROM mock_items
WHERE id @@@ paradedb.match('description', 'running shoes');

The JSON object and query builder function syntaxes are interchangeable, giving you the freedom to decide what’s easier for your application to write.

The JSON 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.

SELECT id, description, created_at FROM mock_items WHERE mock_items @@@ '{
    "range": {
        "field": "created_at",
        "lower_bound": {"included": "2023-05-01T08:12:34Z"},
        "upper_bound": null,
        "is_datetime": true
    }
}'::jsonb
ORDER BY id;