How Search Works
Knowledge.search() passes the query, result limit, and filters to the configured vector database. The database returns Document objects in its ranked order.
Install the PgVector example dependencies and run PostgreSQL with pgvector enabled:
Search Types
Search algorithms differ by vector database. Evaluate each supported search type with representative queries and expected documents.
Direct and Agentic Retrieval
Passknowledge to an agent to register the search_knowledge_base tool. search_knowledge=True is the default.
- Direct Search
- Agentic RAG
search_knowledge_base. Set add_knowledge_to_context=True to retrieve knowledge for each string input and add the results to the model context.
Filtering Results
Filter searches by metadata:OR, NOT, and comparison operators, see Filtering.
Custom Retrieval Logic
Setknowledge_retriever to replace the default Knowledge.retrieve() path:
Retrieval Decisions
Test Retrieval
Compare results with a set of queries and expected documents:Next Steps
Hybrid Search
Configure vector and lexical retrieval signals
Filtering
Apply metadata filters to knowledge searches
Vector DB
Compare storage and search integrations
Performance Tips
Tune ingestion and retrieval settings