pub struct VectorStore { /* private fields */ }Expand description
Main vector store
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn new(provider: Arc<EmbeddingBackend>) -> Self
pub fn new(provider: Arc<EmbeddingBackend>) -> Self
Create new vector store
Sourcepub fn with_storage(self, path: impl Into<PathBuf>) -> Self
pub fn with_storage(self, path: impl Into<PathBuf>) -> Self
Set storage path for persistence
Sourcepub fn with_chunker(self, chunker: CodeChunker) -> Self
pub fn with_chunker(self, chunker: CodeChunker) -> Self
Set chunker
Sourcepub fn collection(
&mut self,
name: &str,
scope: CollectionScope,
) -> &mut VectorCollection
pub fn collection( &mut self, name: &str, scope: CollectionScope, ) -> &mut VectorCollection
Create or get collection
Sourcepub fn get_collection(&self, name: &str) -> Option<&VectorCollection>
pub fn get_collection(&self, name: &str) -> Option<&VectorCollection>
Get collection by name
Sourcepub fn list_collections(&self) -> Vec<&str>
pub fn list_collections(&self) -> Vec<&str>
List all collections
Sourcepub fn delete_collection(&mut self, name: &str) -> Option<VectorCollection>
pub fn delete_collection(&mut self, name: &str) -> Option<VectorCollection>
Delete collection, including its on-disk files.
Sourcepub async fn index_file(
&mut self,
collection_name: &str,
file_path: &Path,
) -> Result<usize>
pub async fn index_file( &mut self, collection_name: &str, file_path: &Path, ) -> Result<usize>
Index a file into a collection
Sourcepub async fn rebuild_index(&mut self, collection_name: &str) -> Result<()>
pub async fn rebuild_index(&mut self, collection_name: &str) -> Result<()>
Rebuild the index for a collection from its stored chunks.
This discards the current index and reconstructs it by re-embedding
every chunk in the collection. Useful when check_health() reports
IndexHealth::Corrupt.
Sourcepub async fn search(
&self,
collection_name: &str,
query: &str,
k: usize,
filter: Option<&SearchFilter>,
) -> Result<Vec<SearchResult>>
pub async fn search( &self, collection_name: &str, query: &str, k: usize, filter: Option<&SearchFilter>, ) -> Result<Vec<SearchResult>>
Search across collection.
If all raw similarity scores are NaN a warning is logged. Callers
that hold a mutable reference can use Self::search_or_rebuild instead
to automatically rebuild the index and retry.
Sourcepub async fn search_or_rebuild(
&mut self,
collection_name: &str,
query: &str,
k: usize,
filter: Option<&SearchFilter>,
) -> Result<Vec<SearchResult>>
pub async fn search_or_rebuild( &mut self, collection_name: &str, query: &str, k: usize, filter: Option<&SearchFilter>, ) -> Result<Vec<SearchResult>>
Search with automatic index rebuild on corruption.
If the initial search produces only NaN scores the index is rebuilt from the source chunks and the search is retried once.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save store to disk.
Uses atomic writes (temp file + rename) for each file to prevent
corruption if the process crashes mid-write. Both the .json and
.idx files for a collection are written atomically.
Sourcepub fn stats(&self) -> VectorStoreStats
pub fn stats(&self) -> VectorStoreStats
Get store statistics
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§
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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::Request