Retrieval
Vector Search
Vector search settings can be configured both server-side and at runtime. Runtime settings are passed as a dictionary to the search and RAG endpoints. You may refer to the search API documentation here for additional materials.
Example using the Python SDK:
vector_search_settings = {
"use_vector_search": True,
"filters": {"document_type": "article"},
"search_limit": 20,
"use_hybrid_search": True,
"selected_collection_ids": ["c3291abf-8a4e-5d9d-80fd-232ef6fd8526"]
}
response = client.search("query", vector_search_settings=vector_search_settings)
Configurable Parameters
VectorSearchSettings
use_vector_search
(bool): Whether to use vector searchuse_hybrid_search
(bool): Whether to perform a hybrid search (combining vector and keyword search)filters
(dict): Filters to apply to the vector searchsearch_limit
(int): Maximum number of results to return (1-1000)selected_collection_ids
(list[UUID]): Group IDs to search forindex_measure
(IndexMeasure): The distance measure to use for indexing (cosine_distance, l2_distance, or max_inner_product)include_values
(bool): Whether to include search score values in the search resultsinclude_metadatas
(bool): Whether to include element metadata in the search resultsprobes
(Optional[int]): Number of ivfflat index lists to query (default: 10)ef_search
(Optional[int]): Size of the dynamic candidate list for HNSW index search (default: 40)hybrid_search_settings
(Optional[HybridSearchSettings]): Settings for hybrid search
HybridSearchSettings
full_text_weight
(float): Weight to apply to full text search (default: 1.0)semantic_weight
(float): Weight to apply to semantic search (default: 5.0)full_text_limit
(int): Maximum number of results to return from full text search (default: 200)rrf_k
(int): K-value for RRF (Rank Reciprocal Fusion) (default: 50)
Advanced Filtering
R2R supports complex filtering using PostgreSQL-based queries. Allowed operators include:
eq
,neq
: Equality and inequalitygt
,gte
,lt
,lte
: Greater than, greater than or equal, less than, less than or equallike
,ilike
: Pattern matching (case-sensitive and case-insensitive)in
,nin
: Inclusion and exclusion in a list of values
Example of advanced filtering:
filters = {
"$and": [
{"publication_date": {"$gte": "2023-01-01"}},
{"author": {"$in": ["John Doe", "Jane Smith"]}},
{"category": {"$ilike": "%technology%"}}
]
}
vector_search_settings["filters"] = filters
Was this page helpful?