pub struct FederatedSearch { /* private fields */ }Expand description
Concurrent search over multiple AsyncVectorIndex backends.
Queries every backend at once, applies a per-backend timeout so one slow
remote cannot stall the whole query, drops failing or timed-out backends
with an observable tracing::warn!, and merges the survivors with the
configured FusionStrategy. If every backend fails, returns
KernelError::Search.
Synchronous backends (e.g. TurbovecIndex) participate via
federate_results instead — search them
directly and fold the list in.
Implementations§
Source§impl FederatedSearch
impl FederatedSearch
Sourcepub fn with_backend(self, index: Arc<dyn AsyncVectorIndex>, weight: f32) -> Self
pub fn with_backend(self, index: Arc<dyn AsyncVectorIndex>, weight: f32) -> Self
Add a backend with a fusion weight (used only by
FusionStrategy::WeightedSum; ignored by RRF).
Sourcepub fn strategy(self, strategy: FusionStrategy) -> Self
pub fn strategy(self, strategy: FusionStrategy) -> Self
Set the fusion strategy (default FusionStrategy::Rrf k=60).
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set the per-backend query timeout (default 5s). A backend that exceeds it is dropped with a warning rather than blocking the query.
Sourcepub async fn search(
&self,
query: &[f32],
k_req: usize,
) -> Result<Vec<SearchResult>>
pub async fn search( &self, query: &[f32], k_req: usize, ) -> Result<Vec<SearchResult>>
Run query against every backend concurrently, merge survivors.
Each backend is queried for 2 * k results (over-fetch) so RRF
rank-credit is preserved for a document that ranks just below k in
one backend but near the top in another; the fused list is then
truncated to the requested k. A per-backend timeout drops slow or
failing backends with an observable tracing::warn! rather than
stalling the query.
Returns the fused result list (at most k items).
KernelError::Search is returned only when no backend succeeded;
one or more survivors yield a partial (but non-empty) merged result.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FederatedSearch
impl !UnwindSafe for FederatedSearch
impl Freeze for FederatedSearch
impl Send for FederatedSearch
impl Sync for FederatedSearch
impl Unpin for FederatedSearch
impl UnsafeUnpin for FederatedSearch
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.