Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.paradedb.com/llms.txt

Use this file to discover all available pages before exploring further.

The BM25 index accepts arrays of type text[] or varchar[].
CREATE TABLE array_demo (id SERIAL PRIMARY KEY, categories TEXT[]);
INSERT INTO array_demo (categories) VALUES
    ('{"food","groceries and produce"}'),
    ('{"electronics","computers"}'),
    ('{"books","fiction","mystery"}');
CREATE INDEX search_idx ON array_demo
USING bm25 (id, categories)
WITH (key_field = 'id');
Under the hood, each element in the array is indexed as a separate entry. This means that an array is considered a match if any of its entries is a match.
SELECT * FROM array_demo WHERE categories === 'food';
Expected Response
 id |           categories
----+--------------------------------
  1 | {food,"groceries and produce"}
(1 row)
Text arrays can be tokenized and filtered in the same way as text fields:
CREATE INDEX search_idx ON array_demo
USING bm25 (id, (categories::pdb.literal))
WITH (key_field = 'id');