pub struct Database {
pub data_path: String,
pub index_path: String,
pub bm25_index_path: String,
pub index: Index,
pub bm25_index: Bm25Index,
pub bm25_tokenizer: Tokenizer,
pub hnsw: HNSW,
pub graph_path: String,
}Fields§
§data_path: String§index_path: String§bm25_index_path: String§index: Index§bm25_index: Bm25Index§bm25_tokenizer: Tokenizer§hnsw: HNSW§graph_path: StringImplementations§
Source§impl Database
impl Database
pub fn new( data_path: &str, index_path: &str, bm25_index_path: &str, hnsw_path: &str, graph_path: &str, ) -> Database
Sourcepub fn insert_raw(&mut self, vector: Vec<f32>, text: &str, id: Option<&str>)
pub fn insert_raw(&mut self, vector: Vec<f32>, text: &str, id: Option<&str>)
Insert a record with a pre-computed embedding vector and text metadata.
id pins the record to a specific key; pass None to auto-generate a UUID v7.
The text is indexed into BM25 for full-text search; the vector is inserted into the HNSW graph.
pub fn text_search(&self, query: &str, k: usize) -> Vec<Record>
Sourcepub fn delete(&mut self, id: &str) -> bool
pub fn delete(&mut self, id: &str) -> bool
Delete a record by UUID. Returns false if the ID was not found.
Sourcepub fn search_scored(
&self,
query_vector: &[f32],
k: usize,
) -> Vec<(f32, Record)>
pub fn search_scored( &self, query_vector: &[f32], k: usize, ) -> Vec<(f32, Record)>
Brute-force cosine-similarity search over all stored vectors. Returns up to k records sorted by descending score. Useful for recall evaluation against HNSW results.
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
impl UnwindSafe for Database
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