hybrid-search-implementation

Implement hybrid search combining vector similarity and keyword matching with RRF fusion.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill hybrid-search-implementation-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hybrid-search-implementation
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/hybrid-search-implementation
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill hybrid-search-implementation-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires asyncpg, numpy, elasticsearch, sentence-transformers.

What problem does it solve? Pure vector search misses exact keyword matches like names, codes, and domain-specific terms, while pure keyword search lacks semantic understanding. This Skill provides patterns and templates for combining both approaches to improve retrieval recall in RAG systems and search engines. ## Core Features & Use Cases - Fusion Methods: Implement Reciprocal Rank Fusion (RRF), linear score combination, cross-encoder reranking, and cascade filtering to merge vector and keyword results. - Database Templates: Ready-to-use implementations for PostgreSQL with pgvector and full-text search, and Elasticsearch with dense vectors and BM25. - Complete RAG Pipeline: A custom HybridRAGPipeline class that orchestrates parallel searches, fusion, and optional cross-encoder reranking. - Use Case: When building a documentation search where users query exact error codes alongside natural language questions, use the PostgreSQL hybrid template to retrieve candidates from both vector and full-text indexes, then fuse with RRF. ## Quick Start Ask the AI to implement a hybrid search in PostgreSQL that combines pgvector embeddings with full-text search and fuses results using reciprocal rank fusion.

Frequently Asked Questions about hybrid-search-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine vector search and keyword search in Python?

Combine vector and keyword search using Reciprocal Rank Fusion, which scores each document as the sum of 1/(k + rank) across both result lists. Run both searches in parallel, then merge rankings with the RRF formula using k=60 as the default constant.

What is reciprocal rank fusion in hybrid search?

Reciprocal Rank Fusion is a method that combines multiple ranked result lists by summing 1/(k + rank) for each document across lists. It works well without tuning and handles the different score scales of vector similarity and BM25 keyword scores.

How to implement hybrid search in PostgreSQL with pgvector?

Create a table with a vector column indexed by HNSW and a generated tsvector column indexed by GIN. Query both with CTEs for vector and full-text search, then join results with FULL OUTER JOIN and compute an RRF score from the two rankings.

Does Elasticsearch support hybrid search with RRF?

Elasticsearch 8.x supports native RRF through the rank parameter with sub_searches combining a match query and a kNN query. For older versions, combine script_score cosine similarity with a boosted match query in a bool should clause.

When should I use hybrid search instead of pure vector search?

Use hybrid search when queries contain exact terms like names, codes, or domain-specific vocabulary that embeddings miss. Pure vector search handles semantic similarity well but often fails on precise keyword matching requirements.

Why does cross-encoder reranking improve hybrid search results?

Cross-encoder reranking scores query-document pairs jointly with a neural model, capturing relevance signals that independent vector and keyword scoring miss. Apply it to the top fused candidates, typically 50, then return the reranked top results.