pub struct Collection { /* private fields */ }Expand description
A collection of vectors with associated metadata.
Implementations§
Source§impl Collection
impl Collection
Sourcepub fn create(
path: PathBuf,
dimension: usize,
metric: DistanceMetric,
) -> Result<Self>
pub fn create( path: PathBuf, dimension: usize, metric: DistanceMetric, ) -> Result<Self>
Creates a new collection at the specified path.
§Errors
Returns an error if the directory cannot be created or the config cannot be saved.
Sourcepub fn open(path: PathBuf) -> Result<Self>
pub fn open(path: PathBuf) -> Result<Self>
Opens an existing collection from the specified path.
§Errors
Returns an error if the config file cannot be read or parsed.
Sourcepub fn config(&self) -> CollectionConfig
pub fn config(&self) -> CollectionConfig
Returns the collection configuration.
Sourcepub fn upsert(&self, points: Vec<Point>) -> Result<()>
pub fn upsert(&self, points: Vec<Point>) -> Result<()>
Inserts or updates points in the collection.
§Errors
Returns an error if any point has a mismatched dimension.
Sourcepub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
pub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
Searches for the k nearest neighbors of the query vector.
Uses HNSW index for fast approximate nearest neighbor search.
§Errors
Returns an error if the query vector dimension doesn’t match the collection.
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
Saves the collection configuration and index to disk.
§Errors
Returns an error if storage operations fail.
Sourcepub fn text_search(&self, query: &str, k: usize) -> Vec<SearchResult>
pub fn text_search(&self, query: &str, k: usize) -> Vec<SearchResult>
Sourcepub fn hybrid_search(
&self,
vector_query: &[f32],
text_query: &str,
k: usize,
vector_weight: Option<f32>,
) -> Result<Vec<SearchResult>>
pub fn hybrid_search( &self, vector_query: &[f32], text_query: &str, k: usize, vector_weight: Option<f32>, ) -> Result<Vec<SearchResult>>
Performs hybrid search combining vector similarity and full-text search.
Uses Reciprocal Rank Fusion (RRF) to combine results from both searches.
§Arguments
vector_query- Query vector for similarity searchtext_query- Text query for BM25 searchk- Maximum number of results to returnvector_weight- Weight for vector results (0.0-1.0, default 0.5)
§Errors
Returns an error if the query vector dimension doesn’t match.
Trait Implementations§
Source§impl Clone for Collection
impl Clone for Collection
Source§fn clone(&self) -> Collection
fn clone(&self) -> Collection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Collection
impl !RefUnwindSafe for Collection
impl Send for Collection
impl Sync for Collection
impl Unpin for Collection
impl !UnwindSafe for Collection
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> 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