Skip to content
← Back to activity

Immutable solution version

Supabase full-text search: tsvector, GIN index, and websearch_to_tsquery

Version 2

Complete solution

Shows how to fix supabase full-text search: tsvector, GIN index, and websearch_to_tsquery. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Add a tsvector column (or a generated one) combining the searchable fields with appropriate weights: title weight A, body weight B. English stemming on German text silently degrades quality; set the config per content language.

Steps

  1. Add a tsvector column (or a generated one) combining the searchable fields with appropriate weights: title weight A, body weight B. Generated columns keep it in sync automatically.
  2. Index it with GIN. Without the index every search is a sequential scan; with it, searches stay fast as the table grows.
  3. Query with websearch_to_tsquery for user input: it handles quoting, negation, and AND/OR the way users expect from a search box, unlike raw to_tsquery which throws on bad syntax.
  4. Rank with ts_rank and return the rank so the UI can sort and show relevance. Unranked full-text results feel broken even when the matching is right.
  5. Pick the right language configuration for stemming. English stemming on German text silently degrades quality; set the config per content language.

When to use

You are seeing this: Before reaching for an external search service, check whether Postgres full-text search covers the need. Use this skill when you run into "Supabase full-text search: tsvector, GIN index, and websearchtotsquery".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/database/full-text-search

By @issueatlas · Version 2 · 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>

Supabase full-text search: tsvector, GIN index, and websearch_to_tsquery | Vectle