Documentation Index Fetch the complete documentation index at: https://agno-v2-shaloo-ai-support-link.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Keyword search finds content by matching exact words and phrases. It uses your database’s full-text search capabilities to find documents containing specific terms.
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector, SearchType
knowledge = Knowledge(
vector_db = PgVector(
table_name = "docs" ,
db_url = db_url,
search_type = SearchType.keyword,
),
)
How It Works
Text parsing : Your query is broken into searchable terms
Index lookup : The system finds documents containing those terms
Ranking : Results are ordered by relevance (term frequency, document length, etc.)
When using PgVector, this leverages PostgreSQL’s built-in full-text search. Other databases use their native text search capabilities.
When to Use Keyword Search
Scenario Why Keyword Search Works Searching for specific terms Exact match on product names, codes, IDs Error codes and identifiers Precise matching without semantic interpretation Technical terminology Users know the exact terms to search Structured data queries Matching specific field values
Use vector search if users phrase things differently than your docs.
Use hybrid search if you want both exact matching and semantic understanding.
Configuration
Basic Setup
from agno.vectordb.pgvector import PgVector, SearchType
vector_db = PgVector(
table_name = "docs" ,
db_url = db_url,
search_type = SearchType.keyword,
)
With Reranking
Add a reranker to improve result ordering:
from agno.knowledge.reranker.cohere import CohereReranker
vector_db = PgVector(
table_name = "docs" ,
db_url = db_url,
search_type = SearchType.keyword,
reranker = CohereReranker(),
)
Example
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector, SearchType
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
vector_db = PgVector(
table_name = "recipes" ,
db_url = db_url,
search_type = SearchType.keyword,
),
)
# Load content
knowledge.insert(
url = "https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ,
)
# Search by exact terms
results = knowledge.search( "chicken coconut soup" , max_results = 5 )
for doc in results:
print (doc.content[: 200 ])
Next Steps
Hybrid Search Combine keyword search with vector similarity
Vector Search Search by semantic meaning