lance_db_hybrid_search.py
SearchType.hybrid runs LanceDB’s native vector and full-text search and combines the results.
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export the API key
4
Run the example
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Run LanceDB’s native vector and full-text search together in a single query.
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.vectordb.lancedb import LanceDb, SearchType
knowledge = Knowledge(
vector_db=LanceDb(
table_name="hybrid_recipes",
uri="tmp/lancedb",
search_type=SearchType.hybrid,
)
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
knowledge=knowledge,
search_knowledge=True,
markdown=True,
)
if __name__ == "__main__":
knowledge.insert(
name="Recipes",
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
metadata={"doc_type": "recipe_book"},
)
agent.print_response(
"How do I make chicken and galangal in coconut milk soup?",
stream=True,
)
SearchType.hybrid runs LanceDB’s native vector and full-text search and combines the results.
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno lancedb openai pypdf
Export the API key
export OPENAI_API_KEY=your_openai_api_key_here
Run the example
python lance_db_hybrid_search.py
| Task | Guide |
|---|---|
| Insert, search, and delete content | LanceDB usage |
| Call async Agno methods | Async LanceDB usage |
| Configure search behavior | LanceDB overview |
Was this page helpful?