hybrid-search-implementation

Implement hybrid search pipelines combining vector and keyword results with RRF fusion.

27|10|Updated Dec 27, 2025
One-click install
npx skills add https://github.com/nilecui/SkillsBase --skill hybrid-search-implementation-nilecui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hybrid-search-implementation
Source: https://github.com/nilecui/SkillsBase/tree/main/.cursor/skills/hybrid-search-implementation
Command: npx skills add https://github.com/nilecui/SkillsBase --skill hybrid-search-implementation-nilecui

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires asyncpg, elasticsearch, sentence-transformers, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the limitations of relying solely on keyword or vector search by providing robust strategies to combine both, leading to more accurate and comprehensive search results.

Core Features & Use Cases

  • Hybrid Search Architectures: Implement systems that leverage both semantic understanding (vector search) and exact term matching (keyword search).
  • Fusion Methods: Utilize techniques like Reciprocal Rank Fusion (RRF), linear combination, or cross-encoder reranking to merge results from different search strategies.
  • Use Case: Building a RAG system where a user query might contain specific product codes (best for keyword search) and also abstract concepts (best for vector search). Combining these ensures all relevant information is retrieved.

Quick Start

Implement a hybrid search pipeline using Reciprocal Rank Fusion to combine vector and keyword search results.

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 and keyword search for better RAG retrieval?

Combining vector and keyword search for RAG retrieval leverages both semantic understanding and exact term matching. You can merge results using fusion methods like Reciprocal Rank Fusion (RRF), linear combination, or cross-encoder reranking to significantly improve search recall.

What is Reciprocal Rank Fusion in hybrid search?

Reciprocal Rank Fusion (RRF) in hybrid search is a technique to merge result rankings from vector and keyword search engines. It calculates a unified score based on the reciprocal of each document's rank across different search strategies, requiring no manual weight tuning.

Does this hybrid search implementation work with PostgreSQL and Elasticsearch?

Yes, this hybrid search implementation works with PostgreSQL and Elasticsearch. It provides ready-to-use templates for both databases, allowing you to execute combined vector and keyword search queries directly within your existing data infrastructure.

When should I use cross-encoder reranking instead of linear combination for search results?

Use cross-encoder reranking instead of linear combination when you need higher precision in your final search results. Cross-encoders evaluate query-document pairs together for deeper semantic matching, whereas linear combination simply blends scores from separate vector and keyword searches.

How to handle RAG queries containing both product codes and abstract concepts?

To handle RAG queries containing both product codes and abstract concepts, implement a hybrid search architecture. This ensures exact term matching captures the specific product codes while vector search retrieves the abstract conceptual information simultaneously.

What dependencies do I need to run a hybrid search pipeline?

To run this hybrid search pipeline, you need the asyncpg library for PostgreSQL access, elasticsearch for keyword and document indexing, and sentence-transformers to generate the vector embeddings required for semantic search queries.