Prerequisite Before performing full text search over a table, it must first be indexed.

Basic Usage

Every BM25 index comes with a search function, which returns rows of a table that match a search query. By default, rows are sorted by relevance.

SELECT * FROM search_idx.search('<query>');

Query Language

The query string accepts a mini query language which can be used to construct expressive queries.

Each query must specify which field to search over. In the following example, we are querying for keyboard against the description field.

SELECT * FROM search_idx.search('description:keyboard');

Search Options

search accepts additional arguments for pagination and sorting.

SELECT * FROM search_idx.search('description:keyboard', limit_rows => 10);
limit_rows

The maximum number of rows to return. Defaults to the number of documents in the index. Providing a limit_rows can significantly improve query times.

offset_rows
default: 0

The offset of the result set.

stable_sort
default: false

If set to true, equally-scored results will be sorted by key_field.

order_by_field

If provided, results will be ordered by this field instead of by relevance.

order_by_direction
default: "asc"

Configures whether order_by_field orders in ascending or descending order. Ascending is asc, descending is desc.

lenient_parsing
default: false

If set to true, the query parser will attempt to construct a valid query on a best-effort basis, ignoring invalid components such as missing or non-existent fields.

conjunction_mode
default: false

If set to true, the search function employs conjunction (AND) logic by default.