What is Hybrid Search?
Hybrid search leverages two complementary approaches:- Vector Search (KNN) - Finds semantically similar content using embedding vectors
- Full-Text Search (BM25) - Finds keyword matches using traditional information retrieval
Basic Hybrid Search
Setting Up
First, create a collection with hybrid search support:Adding Documents
Performing Hybrid Search
Understanding the Components
KNN (K-Nearest Neighbors)
Vector similarity search finds semantically similar content:- Finding semantically related content
- Handling synonyms and paraphrases
- Cross-lingual search (with multilingual models)
BM25 (Full-Text Search)
Keyword-based search using the BM25 algorithm:- Exact keyword matching
- Technical terms and jargon
- Proper nouns and specific phrases
RRF (Reciprocal Rank Fusion)
Combines multiple search results:k parameter controls the fusion:
- Lower
k(e.g., 20): Emphasizes top-ranked results - Higher
k(e.g., 100): Gives more weight to lower-ranked results - Default:
k=60(balanced)
Advanced Hybrid Search
With Metadata Filtering
Multi-Query Hybrid Search
Search with multiple queries:Custom Scoring
Adjust the balance between vector and keyword search:Using BM25 Embedding Function
Chroma provides a built-in BM25 embedding function for full-text search:Real-World Use Cases
E-commerce Product Search
- Finds products by features (semantic)
- Matches exact brand/model names (keyword)
- Ranks by relevance (hybrid)
Document Retrieval
Question Answering
Performance Optimization
Tuning Parameters
Caching
Batch Processing
Comparison: Hybrid vs. Single Method
When to Use Hybrid Search
✅ Use hybrid search when:- You need both semantic and exact matching
- Queries contain technical terms or proper nouns
- You want robust results across query types
- Handling diverse user queries
When to Use Vector Search Only
✅ Use vector search when:- Semantic similarity is more important than keywords
- Working with multilingual content
- Queries are questions or natural language
- Handling paraphrases and synonyms
When to Use Keyword Search Only
✅ Use keyword search when:- Exact term matching is critical
- Searching for codes, IDs, or specific phrases
- Working with structured data
- Speed is the priority