pub struct SearchQuery {
pub query: QueryType,
pub limit: usize,
pub min_score: f32,
pub filters: HashMap<String, Value>,
pub config: SearchConfig,
}Expand description
A search query with comprehensive configuration options
Encapsulates all parameters for a search operation including the query itself, result limits, filtering criteria, and algorithm configuration. Supports both text queries (that will be embedded) and pre-computed embedding queries.
§Example
use rrag::prelude::*;
// Simple text query
let query = SearchQuery::new("machine learning algorithms")
.with_limit(10)
.with_min_score(0.7);
// Advanced query with filters
let advanced_query = SearchQuery::new("neural networks")
.with_limit(20)
.with_min_score(0.6)
.with_filter("category", "research".into())
.with_filter("year", 2023.into())
.with_config(SearchConfig {
algorithm: SearchAlgorithm::CosineSimilarity,
enable_reranking: true,
include_embeddings: true,
..Default::default()
});
// Query with pre-computed embedding
let embedding_query = SearchQuery::from_embedding(embedding)
.with_limit(5);§Filter Types
Filters support various data types:
- Strings: Exact match or pattern matching
- Numbers: Range queries and exact values
- Dates: Date range filtering
- Arrays: “Contains” operations
- Booleans: Exact boolean matching
Fields§
§query: QueryTypeQuery text or embedding
limit: usizeMaximum number of results to return
min_score: f32Minimum similarity threshold
filters: HashMap<String, Value>Metadata filters
config: SearchConfigSearch configuration
Implementations§
Source§impl SearchQuery
impl SearchQuery
Sourcepub fn with_limit(self, limit: usize) -> Self
pub fn with_limit(self, limit: usize) -> Self
Set result limit
Sourcepub fn with_min_score(self, min_score: f32) -> Self
pub fn with_min_score(self, min_score: f32) -> Self
Set minimum score threshold
Sourcepub fn with_filter(self, key: impl Into<String>, value: Value) -> Self
pub fn with_filter(self, key: impl Into<String>, value: Value) -> Self
Add metadata filter
Sourcepub fn with_config(self, config: SearchConfig) -> Self
pub fn with_config(self, config: SearchConfig) -> Self
Set search configuration
Trait Implementations§
Source§impl Clone for SearchQuery
impl Clone for SearchQuery
Source§fn clone(&self) -> SearchQuery
fn clone(&self) -> SearchQuery
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SearchQuery
impl RefUnwindSafe for SearchQuery
impl Send for SearchQuery
impl Sync for SearchQuery
impl Unpin for SearchQuery
impl UnwindSafe for SearchQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more