Skip to main content

AggregateHybridQuery

Struct AggregateHybridQuery 

Source
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_score

where vector_similarity = (2 - vector_distance) / 2 and text_score = @__score (the scorer output).

Implementations§

Source§

impl<'a> AggregateHybridQuery<'a>

Source

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.

Source

pub fn with_alpha(self, alpha: f32) -> Self

Sets the weight of the vector similarity in the hybrid score.

Source

pub fn with_num_results(self, num_results: usize) -> Self

Sets the number of results to return.

Source

pub fn with_text_scorer(self, scorer: impl Into<String>) -> Self

Sets the text scorer algorithm (e.g. "BM25STD", "TFIDF").

Source

pub fn with_filter(self, filter_expression: FilterExpression) -> Self

Attaches a filter expression.

Source

pub fn with_return_fields<I, S>(self, return_fields: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Replaces the return field list.

Source

pub fn with_stopwords(self, stopwords: HashSet<String>) -> Self

Sets stopwords to filter from the query text.

Source

pub fn with_text_weights(self, weights: HashMap<String, f32>) -> Self

Sets word weights for the text search.

Source

pub fn set_text_weights(&mut self, weights: HashMap<String, f32>)

Updates text weights after construction (mirrors Python set_text_weights).

Source

pub fn with_dialect(self, dialect: u32) -> Self

Sets the Redis dialect version.

Source

pub fn vector(&self) -> &Vector<'a>

Returns the encoded query vector.

Source

pub fn alpha(&self) -> f32

Returns the configured alpha value.

Source

pub fn text(&self) -> &str

Returns the query text.

Source

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>

Source§

fn clone(&self) -> AggregateHybridQuery<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for AggregateHybridQuery<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more