pub struct DistributedIndex { /* private fields */ }Expand description
Distributed vector search index with sharding and replication.
Splits vectors across multiple shards for horizontal scaling. Supports replication for fault tolerance.
Implementations§
Source§impl DistributedIndex
impl DistributedIndex
Sourcepub fn new(shard_config: ShardConfig, search_config: SearchConfig) -> Self
pub fn new(shard_config: ShardConfig, search_config: SearchConfig) -> Self
Create a new distributed index.
Sourcepub fn build(&mut self, embeddings: &HashMap<String, Vec<f32>>) -> Result<()>
pub fn build(&mut self, embeddings: &HashMap<String, Vec<f32>>) -> Result<()>
Build the distributed index from embeddings.
Automatically distributes vectors across shards using consistent hashing.
Sourcepub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
pub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
Search across all shards and merge results.
Performs a fan-out search to all shards in parallel, then merges and re-ranks results.
Sourcepub fn batch_search(
&self,
queries: &[Vec<f32>],
k: usize,
) -> Result<Vec<Vec<SearchResult>>>
pub fn batch_search( &self, queries: &[Vec<f32>], k: usize, ) -> Result<Vec<Vec<SearchResult>>>
Batch search for multiple queries across all shards.
Performs multiple searches in parallel and returns results for each query.
Sourcepub fn filtered_search(
&self,
query: &[f32],
k: usize,
filter: &Filter,
) -> Result<Vec<SearchResult>>
pub fn filtered_search( &self, query: &[f32], k: usize, filter: &Filter, ) -> Result<Vec<SearchResult>>
Search with metadata filtering across all shards.
Applies the filter to each shard before merging results.
Sourcepub fn set_metadata(&mut self, entity_id: &str, metadata: Metadata)
pub fn set_metadata(&mut self, entity_id: &str, metadata: Metadata)
Set metadata for an entity across all replica shards.
Sourcepub fn get_metadata(&self, entity_id: &str) -> Option<Metadata>
pub fn get_metadata(&self, entity_id: &str) -> Option<Metadata>
Get metadata for an entity from the primary shard.
Sourcepub fn batch_set_metadata(&mut self, metadata_map: &HashMap<String, Metadata>)
pub fn batch_set_metadata(&mut self, metadata_map: &HashMap<String, Metadata>)
Set metadata for multiple entities in batch.
Sourcepub fn get_stats(&self) -> Result<DistributedStats>
pub fn get_stats(&self) -> Result<DistributedStats>
Get statistics about the distributed index.
Auto Trait Implementations§
impl Freeze for DistributedIndex
impl RefUnwindSafe for DistributedIndex
impl Send for DistributedIndex
impl Sync for DistributedIndex
impl Unpin for DistributedIndex
impl UnwindSafe for DistributedIndex
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> 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