Tooluck logoTooluck
SKILL.md

postgres-hybrid-text-search

Agent skill fromtimescale/pg-aiguide

Use this skill to implement hybrid search combining BM25 keyword search with semantic vector search using Reciprocal Rank Fusion (RRF). **Trigger when user asks to:** - Combine keyword and semantic search - Implement hybrid search or multi-modal retrieval - Use BM25/pg_textsearch with pgvector together - Implement RRF (Reciprocal Rank Fusion) for search - Build search that handles both exact terms and meaning **Keywords:** hybrid search, BM25, pg_textsearch, RRF, reciprocal rank fusion, keyword search, full-text search, reranking, cross-encoder Covers: pg_textsearch BM25 index setup, parallel query patterns, client-side RRF fusion (Python/TypeScript), weighting strategies, and optional ML reranking.

How to install postgres-hybrid-text-search

install postgres-hybrid-text-search
# install the pg-aiguide pack with the skills CLI
npx skills add timescale/pg-aiguide

# or add only this skill to Claude Code: copy the folder

skills/postgres-hybrid-text-search/

# into

~/.claude/skills/postgres-hybrid-text-search/ (all projects)

.claude/skills/postgres-hybrid-text-search/ (one project)

skills/postgres-hybrid-text-search/SKILL.md

Apache-2.0Full file
1# Hybrid Text Search
2
3Hybrid search combines keyword search (BM25) with semantic search (vector embeddings) to get the best of both: exact keyword matching and meaning-based retrieval. Use Reciprocal Rank Fusion (RRF) to merge results from both methods into a single ranked list.
4
5This guide covers combining [pg_textsearch](https://github.com/timescale/pg_textsearch) (BM25) with [pgvector](https://github.com/pgvector/pgvector). Requires both extensions. For high-volume setups, filtering, or advanced pgvector tuning (binary quantization, HNSW parameters), see the **pgvector-semantic-search** skill.
6
7pg_textsearch is a new BM25 text search extension for PostgreSQL, fully open-source and available hosted on Tiger Cloud as well as for self-managed deployments. It provides true BM25 ranking, which often improves relevance compared to PostgreSQL's built-in ts_rank and can offer better performance at scale. Note: pg_textsearch is currently in prerelease and not yet recommended for production use. pg_textsearch currently supports PostgreSQL 17 and 18.
8
9## When to Use Hybrid Search
10
11- **Use hybrid** when queries mix specific terms (product names, codes, proper nouns) with conceptual intent
12- **Use semantic only** when meaning matters more than exact wording (e.g., "how to fix slow queries" should match "query optimization")
13- **Use keyword only** when exact matches are critical (e.g., error codes, SKUs, legal citations)
14…

Excerpt shown under the repository's Apache-2.0 license.

More skills in pg-aiguide

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates