pub struct VectorStore { /* private fields */ }Expand description
A bounded vector store with semantic search.
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn with_embedder(embedder: TextEmbedder) -> Self
pub fn with_embedder(embedder: TextEmbedder) -> Self
Vector store using a custom embedder.
Sourcepub fn add(
&mut self,
key: &str,
vector: Vector,
metadata: Option<String>,
) -> bool
pub fn add( &mut self, key: &str, vector: Vector, metadata: Option<String>, ) -> bool
Add a vector to the store. Returns false if the store is full.
Sourcepub fn add_text(
&mut self,
key: &str,
text: &str,
metadata: Option<String>,
) -> bool
pub fn add_text( &mut self, key: &str, text: &str, metadata: Option<String>, ) -> bool
Add text to the store by embedding it.
Sourcepub fn search(&self, query: &Vector, k: usize) -> Vec<SearchResult>
pub fn search(&self, query: &Vector, k: usize) -> Vec<SearchResult>
Search for the k nearest neighbors by cosine similarity. Returns results sorted by descending similarity.
Sourcepub fn search_text(&self, query_text: &str, k: usize) -> Vec<SearchResult>
pub fn search_text(&self, query_text: &str, k: usize) -> Vec<SearchResult>
Search by text (embeds the query first).
Sourcepub fn get(&self, key: &str) -> Option<&StoredVector>
pub fn get(&self, key: &str) -> Option<&StoredVector>
Get a vector by key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VectorStore
impl RefUnwindSafe for VectorStore
impl Send for VectorStore
impl Sync for VectorStore
impl Unpin for VectorStore
impl UnsafeUnpin for VectorStore
impl UnwindSafe for VectorStore
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.