Case-insensitive pattern matching search using SQL ILIKE operator. Results are ordered by the fields being searched within in the order specified, then by ID for tie-breaking and stable pagination.
Standard pagination with ORDER BY. Results are ordered by the specified orderBy fields, with ID field automatically included for stable pagination if not already present.
Similarity search using PostgreSQL trigram similarity. Results are ordered by exact match priority, then by similarity score, then by specified extra order by fields if provided, then by ID for tie-breaking and stable pagination.
Performance considerations:
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX idx_table_field_trigram ON table_name USING gin(field_name gin_trgm_ops);
-- Or for multiple columns:
CREATE INDEX idx_table_search ON table_name USING gin((field1 || ' ' || field2) gin_trgm_ops);
Search strategy for SQL-based pagination.