Retrieval
Search and RAG capabilities using the R2R CLI.
Retrieval Operations
The R2R CLI provides two main retrieval commands: search
and rag
(Retrieval-Augmented Generation). These commands allow you to query your document collection and generate AI-powered responses based on the retrieved content.
Search Command
The search
command performs document retrieval using vector search and/or knowledge graph search capabilities.
Vector Search Options
--use-vector-search
: Enable vector search (default: true)--filters
: Apply JSON filters to the search results--search-limit
: Maximum number of search results to return--use-hybrid-search
: Enable hybrid search combining vector and keyword search--selected-collection-ids
: Specify collection IDs to search within as JSON array--search-strategy
: Choose between “vanilla” search or advanced methods like query fusion or HyDE
Knowledge Graph Search Options
--use-kg-search
: Enable knowledge graph search--kg-search-type
: Choose between “local” or “global” search--kg-search-level
: Specify the level for global KG search--entity-types
: Filter by entity types (as JSON)--relationships
: Filter by relationship types (as JSON)--max-community-description-length
: Set maximum length for community descriptions--local-search-limits
: Set limits for local search (as JSON)
RAG Command
The rag
command combines search capabilities with AI generation to provide contextual responses based on your document collection.
Generation Options
--stream
: Stream the response in real-time--rag-model
: Specify the model to use for generation
Vector Search Settings
--use-vector-search
: Enable vector search (default: true)--filters
: Apply JSON filters to search results--search-limit
: Maximum number of search results (default: 10)--use-hybrid-search
: Enable hybrid search--selected-collection-ids
: Specify collection IDs to search within--search-strategy
: Choose search method (default: “vanilla”)
Knowledge Graph Settings
--use-kg-search
: Enable knowledge graph search--kg-search-type
: Set to “local” or “global” (default: “local”)--kg-search-level
: Specify cluster level for Global KG search--kg-search-model
: Choose the model for KG agent--entity-types
: Filter by entity types (as JSON)--relationships
: Filter by relationship types (as JSON)--max-community-description-length
: Set maximum community description length--local-search-limits
: Set limits for local search (as JSON)
Examples
Basic Search
Advanced Search
Basic RAG
Advanced RAG
Tips for Effective Retrieval
-
Refine Your Queries: Be specific and clear in your search queries to get more relevant results.
-
Use Filters: Narrow down results using filters when you know specific document characteristics.
-
Combine Search Types: Use hybrid search and knowledge graph capabilities together for more comprehensive results.
-
Adjust Search Limits: Modify the search limit based on your needs - higher limits for broad topics, lower limits for specific queries.
-
Stream Long Responses: Use the
--stream
option with RAG for better user experience with longer generations.