Add Google-level search to your PostgreSQL database in 5 minutes
BM25 ranking • Hybrid search • Built for apps and AI agents
Blog • Docs • Tiger Data Console
This demo showcases Tiger Data's pg_textsearch extension, which brings BM25 ranking and hybrid search directly into PostgreSQL.
| Native PostgreSQL | BM25 (pg_textsearch) |
|---|---|
| ❌ Boolean AND — missing one term excludes the doc | ✅ Ranked retrieval — all relevant docs scored |
| ❌ No IDF — common words weighted same as rare | ✅ Rare terms get higher importance |
| ❌ Long docs always win | ✅ Length normalization for fair ranking |
| ❌ Keyword stuffing games rankings | ✅ Term frequency saturation prevents gaming |
Plus: Combine with pgvectorscale for hybrid search — keyword + semantic in one query!
Sign up at console.cloud.timescale.com and create a new service.
git clone https://github.com/rajaraodv/pg_textsearch_demo.git
cd pg_textsearch_demo
npm installcp .env.example .env.localEdit .env.local with your credentials:
DATABASE_URL=postgresql://tsdbadmin:YOUR_PASSWORD@YOUR_HOST:YOUR_PORT/tsdb?sslmode=require
OPENAI_API_KEY=sk-proj-your-openai-api-keynode scripts/setup-database.jsThis will:
- Enable
pg_textsearchandpgvectorscaleextensions - Create the documents table with sample data
- Generate OpenAI embeddings for vector search
- Create BM25 and DiskANN indexes
npm run devOpen http://localhost:3000 and try the demo queries!
- "database connection pooling" — Shows Boolean AND limitation
- "database authentication" — Demonstrates IDF (rare term weighting)
- "explain analyze postgresql" — Shows length normalization
- "make database faster" — Hybrid combines keyword + semantic
- "fix connection pool problems" — Native fails, BM25/Vector work
- "secure my postgres database" — Natural language → technical docs
- Next.js 15 — React framework
- Tiger Data — PostgreSQL cloud with extensions
- pg_textsearch — BM25 full-text search
- pgvectorscale — Vector search with DiskANN
- OpenAI — text-embedding-3-small for embeddings
MIT

