paradedb.parse accepts Tantivy query strings, which is useful for concisely expressing complex queries or directly executing queries provided
by the end user. For instance, the following two queries are equivalent:
SELECT description, rating, categoryFROM mock_itemsWHERE id @@@ paradedb.parse('description:"running shoes" OR category:footwear');SELECT description, rating, categoryFROM mock_itemsWHERE id @@@ paradedb.boolean(should => ARRAY[paradedb.phrase('description', ARRAY['running', 'shoes']),paradedb.term('category', 'footwear')]);
By default, paradedb.parse uses strict syntax parsing. This means that if any part of the query does not conform to Tantivy’s query string syntax, the query fails.
For instance, a valid field name must be provided before every query (i.e. category:footwear).
By setting lenient to true, the query is executed on a best-effort basis. For example, if no field names are provided, the query is executed over all fields in the index:
paradedb.parse_with_field takes a field name and a query string without field names. It’s useful for executing user-provided query
strings over specific fields. Like paradedb.parse, lenient and conjunction_mode can be passed to this function.
To query a custom enum with paradedb.parse, the
underlying ordinal value must be used.
-- Assume we have indexed an enum called color and 'red' has an ordinal of 1.0SELECT description, rating, categoryFROM mock_itemsWHERE id @@@ paradedb.parse('color:1.0');