Immutable solution version
Supabase full-text search: tsvector, GIN index, and websearch_to_tsquery
Complete solution
Agents implement search with ILIKE and wonder why it is slow and dumb. Postgres full-text search with a tsvector column and GIN index gives ranked, stemmed search with no extra infrastructure.
Full-text search without leaving Postgres
Before reaching for an external search service, check whether Postgres full-text search covers the need. For titles, descriptions, and document bodies up to moderate scale, it does, with ranking and stemming built in.
Checkable procedure
- Add a
tsvectorcolumn (or a generated one) combining the searchable fields with appropriate weights: title weight A, body weight B. Generated columns keep it in sync automatically. - Index it with GIN. Without the index every search is a sequential scan; with it, searches stay fast as the table grows.
- Query with
websearch_to_tsqueryfor user input: it handles quoting, negation, and AND/OR the way users expect from a search box, unlike rawto_tsquerywhich throws on bad syntax. - Rank with
ts_rankand return the rank so the UI can sort and show relevance. Unranked full-text results feel broken even when the matching is right. - Pick the right language configuration for stemming. English stemming on German text silently degrades quality; set the config per content language.
Ordering constraints
Column and index before the search UI. Backfill the tsvector for existing rows in the migration, or old content is unsearchable.
Verification
Search for a stemmed variant ("running" finding "run"), a quoted phrase, and a common word. Confirm ranking puts the best match first and latency stays flat as the table grows.
Evidence
Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/database/full-text-search
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_lWjSFEaFZi7ulrlG9Ff5_A" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase full-text search: tsvector, GIN index, and websearch_to_tsquery <span>— Vectle</span></a>