With Hybrid search, you can get the precision of exact matching with the intelligence of semantic understanding. Combining both approaches will deliver more comprehensive and relevant results in many cases.

What exactly is Hybrid Search?

Hybrid search is a retrieval technique that combines the strengths of both vector search (semantic search) and keyword search (lexical search) to find the most relevant results for a query.

  • Vector search uses embeddings (dense vectors) to capture the semantic meaning of text, enabling the system to find results that are similar in meaning, even if the exact words don’t match.
  • Keyword search (BM25, TF-IDF, etc.) matches documents based on the presence and frequency of exact words or phrases in the query.

Hybrid search blends these approaches, typically by scoring and/or ranking results from both methods, to maximize both precision and recall.

FeatureKeyword SearchVector SearchHybrid Search
Based OnLexical matching (BM25, TF-IDF)Embedding similarity (cosine, dot)Both
StrengthExact matches, relevanceContextual meaningBalanced relevance + meaning
WeaknessNo semantic understandingMisses exact keywordsSlightly heavier in compute
Example Match”chicken soup” = chicken soup”chicken soup” = hot broth with chickenBoth literal and related concepts
Best Use CaseLegal docs, structured dataChatbots, Q&A, semantic searchMultimodal, real-world messy user queries

Why Hybrid Search might be better for your application-

  • Improved Recall: Captures more relevant results missed by pure keyword or vector search.
  • Balanced Precision: Exact matches get priority while also including semantically relevant results.
  • Robust to Ambiguity: Handles spelling variations, synonyms, and fuzzy user intent.
  • Best of Both Worlds: Keywords matter when they should, and meaning matters when needed.

Perfect for real-world apps like recipe search, customer support, legal discovery, etc.

The following vector databases support hybrid search natively or via configurations:

DatabaseHybrid Search Support
pgvector✅ Yes
milvus✅ Yes
lancedb✅ Yes
qdrantdb✅ Yes
weaviate✅ Yes
mongodb✅ Yes (Atlas Vector Search)

Example: Hybrid Search using pgvector

from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.vectordb.pgvector import PgVector, SearchType

# Database URL
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

# Initialize hybrid vector DB
hybrid_db = PgVector(
    table_name="recipes",
    db_url=db_url,
    search_type=SearchType.hybrid  # Hybrid Search
)

# Load PDF knowledge base using hybrid search
knowledge_base = PDFUrlKnowledgeBase(
    urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
    vector_db=hybrid_db,
)

# Load the data into the DB (first-time setup)
knowledge_base.load(recreate=True, upsert=True)

# Run a hybrid search query
results = hybrid_db.search("chicken coconut soup", limit=5)
print("Hybrid Search Results:", results)

See More Examples

For hands-on code and advanced usage, check out these hybrid search examples for each supported vector database here