Postgres full-text search
Search built into the database you already have. No extra service.
Pick it when You already use Postgres and have a small or medium amount of data.
Skip it if You need typo tolerance, instant as-you-type results or fancy ranking.
- Nothing new to run or pay for
- Always in sync, it is the same data
- Plain LIKE '%x%' works for tiny tables
- Basic typo handling
- Ranking and tuning take SQL skill
- Quick to set up
- Cheap while small
- Easy to leave
- Room to grow
PriceFree; part of your database
How to connect it
- Add a generated column that turns your text into a search vector.
- Add an index on that column so searches stay fast.
- Query with a search term and sort by rank.
- Call that query from an API route as the user types.
DATABASE_URL
alter table posts add column fts tsvector
generated always as (to_tsvector('english', title || ' ' || body)) stored;
create index posts_fts_idx on posts using gin (fts);
select id, title from posts
where fts @@ websearch_to_tsquery('english', 'red shoes')
order by ts_rank(fts, websearch_to_tsquery('english', 'red shoes')) desc
limit 20;