Hybrid Search Deep Dive
Content: Hybrid Search Deep Dive
User Intent
"What is hybrid search and why is it the default?"
Operation
SDK Method:
queryContents()withsearchType: SearchTypes.Hybrid(default)GraphQL:
queryContentsqueryCommon Use Cases: Production search, best results, general-purpose queries
What is Hybrid Search?
Hybrid search combines vector search (semantic) and keyword search (exact matching) using Reciprocal Rank Fusion (RRF) to get the best of both worlds.
Why it's the default: It handles diverse query types better than either approach alone, with minimal downside.
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentTypes, EntityState, FileTypes, ObservableTypes, SearchTypes } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Hybrid search (default - can omit searchType)
const results = await graphlit.queryContents({
search: "machine learning applications in healthcare"
});
// Explicit hybrid search
const explicitHybrid = await graphlit.queryContents({
search: "machine learning applications in healthcare",
searchType: SearchTypes.Hybrid // Default value
});
console.log(`Found ${results.contents.results.length} results`);
results.contents.results.forEach((content, index) => {
console.log(`\n${index + 1}. ${content.name}`);
console.log(` Relevance: ${(content.relevance * 100).toFixed(1)}%`);
console.log(` Type: ${content.type}`);
});How Hybrid Search Works
The RRF Algorithm
RRF = Reciprocal Rank Fusion
Example:
Pipeline
Why Hybrid is Best
1. Handles Diverse Queries
2. Better Precision
3. Robust to Query Types
Comparison: Vector vs Keyword vs Hybrid
Sample Results Comparison
Query: "machine learning tutorial"
1
"Deep Learning Guide"
"Machine Learning Tutorial"
"Machine Learning Tutorial" ✓
2
"Neural Network Basics"
"ML Tutorial 2024"
"Deep Learning Guide"
3
"AI Fundamentals"
"Tutorial: Machine Learning"
"ML Tutorial 2024"
4
"ML Concepts"
"Machine Learning Intro"
"Neural Network Basics"
5
"Understanding AI"
"Learn ML"
"Tutorial: Machine Learning"
Winner: Hybrid (exact match ranks #1, semantically similar also included)
Hybrid search (default)
results = await graphlit.queryContents( search="machine learning applications" )
Explicit hybrid
hybrid = await graphlit.queryContents( search="machine learning applications", search_type=SearchTypes.Hybrid )
for content in results.contents.results: print(f"{content.name} - {content.relevance:.3f}")
Developer Hints
Default for Good Reason
No Tuning Parameters
When NOT to Use Hybrid
Performance
Variations
1. Basic Hybrid Search (Default)
2. Hybrid with Filters
3. Hybrid with Collection Filter
4. Hybrid Search Pagination
5. Compare Hybrid vs Pure Approaches
6. Hybrid with Entity Filter
Common Issues & Solutions
Issue: Results not relevant enough Solution: Hybrid is usually best, but check query quality
Issue: Want pure semantic search Solution: Override with Vector search type
Issue: Want pure exact matching Solution: Override with Keyword search type
Issue: Queries slower than expected Solution: Hybrid runs both searches (small overhead acceptable)
Production Example
Sample Reference
Graphlit_2024_09_13_Compare_RAG_strategies.ipynb - Compares search strategies including hybrid
Last updated
Was this helpful?