Overview
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);
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.
The offset of the result set.
If set to true
, equally-scored results will be sorted by key_field
.
If provided, results will be ordered by this field instead of by relevance.
Configures whether order_by_field
orders in ascending or descending order.
Ascending is asc
, descending is desc
.
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.
If set to true
, the search function employs conjunction (AND) logic by
default.
Was this page helpful?