pub struct HnswVectorIndex { /* private fields */ }Expand description
Production-ready vector index backed by HNSW from sochdb-index.
This provides O(log N) search performance vs O(N) for brute-force. Each collection maps to a separate HNSW index.
Implementations§
Source§impl HnswVectorIndex
impl HnswVectorIndex
Sourcepub fn create_collection(&self, name: &str, dimension: usize)
pub fn create_collection(&self, name: &str, dimension: usize)
Create a collection with specified dimension and HNSW parameters
Sourcepub fn insert(
&self,
collection: &str,
id: String,
vector: Vec<f32>,
content: String,
metadata: HashMap<String, SochValue>,
) -> Result<(), String>
pub fn insert( &self, collection: &str, id: String, vector: Vec<f32>, content: String, metadata: HashMap<String, SochValue>, ) -> Result<(), String>
Insert a vector with metadata
Sourcepub fn vector_count(&self, collection: &str) -> Option<usize>
pub fn vector_count(&self, collection: &str) -> Option<usize>
Get collection count for a specific collection
Trait Implementations§
Source§impl Default for HnswVectorIndex
impl Default for HnswVectorIndex
Source§impl VectorIndex for HnswVectorIndex
impl VectorIndex for HnswVectorIndex
Source§fn search_by_embedding(
&self,
collection: &str,
embedding: &[f32],
k: usize,
min_score: Option<f32>,
) -> Result<Vec<VectorSearchResult>, String>
fn search_by_embedding( &self, collection: &str, embedding: &[f32], k: usize, min_score: Option<f32>, ) -> Result<Vec<VectorSearchResult>, String>
Search for k nearest neighbors to the query vector
Auto Trait Implementations§
impl !Freeze for HnswVectorIndex
impl RefUnwindSafe for HnswVectorIndex
impl Send for HnswVectorIndex
impl Sync for HnswVectorIndex
impl Unpin for HnswVectorIndex
impl UnwindSafe for HnswVectorIndex
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
Mutably borrows from an owned value. Read more
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>
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 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>
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