pub struct AggregateHybridQuery<'a> { /* private fields */ }Expand description
Aggregate-based hybrid query that combines text and vector search via
FT.AGGREGATE.
Mirrors the Python AggregateHybridQuery which scores documents as:
hybrid_score = alpha * vector_similarity + (1 - alpha) * text_scorewhere vector_similarity = (2 - vector_distance) / 2 and
text_score = @__score (the scorer output).
Implementations§
Source§impl<'a> AggregateHybridQuery<'a>
impl<'a> AggregateHybridQuery<'a>
Sourcepub fn new(
text: impl Into<String>,
text_field_name: impl Into<String>,
vector: Vector<'a>,
vector_field_name: impl Into<String>,
) -> Result<Self, String>
pub fn new( text: impl Into<String>, text_field_name: impl Into<String>, vector: Vector<'a>, vector_field_name: impl Into<String>, ) -> Result<Self, String>
Creates an aggregate hybrid query.
§Errors
Returns Err if text is empty or becomes empty after stopword
removal.
Sourcepub fn with_alpha(self, alpha: f32) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
Sets the weight of the vector similarity in the hybrid score.
Sourcepub fn with_num_results(self, num_results: usize) -> Self
pub fn with_num_results(self, num_results: usize) -> Self
Sets the number of results to return.
Sourcepub fn with_text_scorer(self, scorer: impl Into<String>) -> Self
pub fn with_text_scorer(self, scorer: impl Into<String>) -> Self
Sets the text scorer algorithm (e.g. "BM25STD", "TFIDF").
Sourcepub fn with_filter(self, filter_expression: FilterExpression) -> Self
pub fn with_filter(self, filter_expression: FilterExpression) -> Self
Attaches a filter expression.
Sourcepub fn with_return_fields<I, S>(self, return_fields: I) -> Self
pub fn with_return_fields<I, S>(self, return_fields: I) -> Self
Replaces the return field list.
Sourcepub fn with_stopwords(self, stopwords: HashSet<String>) -> Self
pub fn with_stopwords(self, stopwords: HashSet<String>) -> Self
Sets stopwords to filter from the query text.
Sourcepub fn with_text_weights(self, weights: HashMap<String, f32>) -> Self
pub fn with_text_weights(self, weights: HashMap<String, f32>) -> Self
Sets word weights for the text search.
Sourcepub fn set_text_weights(&mut self, weights: HashMap<String, f32>)
pub fn set_text_weights(&mut self, weights: HashMap<String, f32>)
Updates text weights after construction (mirrors Python set_text_weights).
Sourcepub fn with_dialect(self, dialect: u32) -> Self
pub fn with_dialect(self, dialect: u32) -> Self
Sets the Redis dialect version.
Sourcepub fn build_aggregate_cmd(&self, index_name: &str) -> Cmd
pub fn build_aggregate_cmd(&self, index_name: &str) -> Cmd
Builds the complete FT.AGGREGATE command for this query.
Matches the Python AggregateRequest.build_args() ordering:
query_string → SCORER → ADDSCORES → LOAD → DIALECT → aggregate plan (APPLY/SORTBY) → PARAMS.
Trait Implementations§
Source§impl<'a> Clone for AggregateHybridQuery<'a>
impl<'a> Clone for AggregateHybridQuery<'a>
Source§fn clone(&self) -> AggregateHybridQuery<'a>
fn clone(&self) -> AggregateHybridQuery<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for AggregateHybridQuery<'a>
impl<'a> RefUnwindSafe for AggregateHybridQuery<'a>
impl<'a> Send for AggregateHybridQuery<'a>
impl<'a> Sync for AggregateHybridQuery<'a>
impl<'a> Unpin for AggregateHybridQuery<'a>
impl<'a> UnsafeUnpin for AggregateHybridQuery<'a>
impl<'a> UnwindSafe for AggregateHybridQuery<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more