Skip to main content
ParadeDB also supports writing query builder functions as JSON objects. This is useful for programmatic generation or client applications that construct search queries as structured JSON. To write a query as JSON, first call SELECT on the desired query builder function, which returns its JSON representation:
SELECT pdb.regex('key.*');
             regex
-------------------------------
 {"regex":{"pattern":"key.*"}}
(1 row)
Next, paste this JSON string into the right-hand side of the @@@ operator and cast it to pdb.query:
SELECT description, rating, category
FROM mock_items
WHERE description @@@
'{
    "regex": {
        "pattern": "key.*"
    }
}'::pdb.query;
The JSON query object must be explicitly cast to pdb.query using ::pdb.query.
I