Last Updated: November 21, 2025
Focus Areas
| Focus |
|---|
Store precomputed `tsvector` columns
|
Use `ts_rank` to order results by relevance
|
Commands & Queries
CREATE INDEX idx_search ON docs USING GIN(tsvector_col)
Index text via GIN
SELECT * FROM docs WHERE to_tsvector('english', body) @@ to_tsquery('fast')
Filter by full-text match
ALTER TABLE docs ADD COLUMN tsvector_col tsvector GENERATED ALWAYS AS ... STORED
Add generated column
Summary
Combine indexes, dictionaries, and ranking to serve relevant results.
💡 Pro Tip:
Keep `tsvector` columns updated via triggers or generated columns.