hybrid-search-implementation

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

Updated May 20, 2026
One-click install
npx skills add https://github.com/TechCorp25/kingdom --skill hybrid-search-implementation-techcorp25
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hybrid-search-implementation
Source: https://github.com/TechCorp25/kingdom/tree/main/.claude/skills/llm-application-dev/skills/hybrid-search-implementation
Command: npx skills add https://github.com/TechCorp25/kingdom --skill hybrid-search-implementation-techcorp25

SYSTEM DOCUMENTATION & REQUIREMENTS

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

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-adapt implementations for PostgreSQL with pgvector and full-text search, and Elasticsearch with dense vectors and native RRF support. - Complete RAG Pipeline: A HybridRAGPipeline class that orchestrates parallel vector and keyword searches, fuses results, and optionally reranks with a cross-encoder. - Use Case: You are building a documentation search where users query exact error codes and natural language questions. Use the PostgreSQL template to run both searches in one SQL query with RRF fusion, then rerank the top candidates for final results. ## Quick Start Ask the AI to implement a hybrid search in PostgreSQL that combines pgvector similarity with full-text search using RRF fusion for your documents table.

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 PostgreSQL?▼

Use pgvector for embedding similarity and PostgreSQL's built-in tsvector full-text search in a single query with CTEs. Compute reciprocal rank fusion scores with ROW_NUMBER over each result set, then join and order by the fused RRF score.

What is reciprocal rank fusion and when should I use it?▼

Reciprocal rank fusion combines ranked lists by summing 1/(k+rank) scores, typically with k=60. Use it as a general-purpose default because it requires no score normalization or weight tuning, unlike linear combination which needs normalized scores.

Does Elasticsearch support hybrid search with RRF natively?▼

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 query instead.

Should I add cross-encoder reranking after hybrid search?▼

Yes, reranking the top candidates with a cross-encoder like ms-marco-MiniLM-L-6-v2 significantly improves result quality. Fetch more candidates than needed, score query-document pairs with the cross-encoder, and return the top results by rerank score.

When is pure vector search not enough for retrieval?▼

Pure vector search underperforms when queries contain exact terms like product codes, proper names, or domain-specific vocabulary that embeddings represent poorly. Hybrid search adds keyword matching to capture these exact matches while retaining semantic understanding.