pub struct LexaDb { /* private fields */ }Implementations§
Source§impl LexaDb
impl LexaDb
pub fn open( path: impl AsRef<Path>, embedding_config: EmbeddingConfig, ) -> Result<Self>
pub fn path(&self) -> &Path
pub fn embedder(&self) -> Result<&Mutex<Embedder>>
pub fn reranker(&self) -> Result<&Mutex<Reranker>>
pub fn index_path(&mut self, path: impl AsRef<Path>) -> Result<usize>
Sourcepub fn index_path_with_preprocessor<P>(
&mut self,
path: impl AsRef<Path>,
preprocessor: Option<&dyn Preprocessor<Payload = P>>,
commit_sidecar: impl Fn(&Transaction<'_>, i64, &P) -> Result<()>,
) -> Result<usize>where
P: Default,
pub fn index_path_with_preprocessor<P>(
&mut self,
path: impl AsRef<Path>,
preprocessor: Option<&dyn Preprocessor<Payload = P>>,
commit_sidecar: impl Fn(&Transaction<'_>, i64, &P) -> Result<()>,
) -> Result<usize>where
P: Default,
Index a path with a per-file preprocessor and sidecar commit hook.
preprocessor is invoked for every supported file before chunking;
it receives the raw bytes and may return Some(PreprocessedDoc) to
substitute the text used for chunking (e.g. strip Obsidian
frontmatter so it doesn’t leak into the embedding) along with a
caller-defined payload of metadata. Returning None skips the
file. Returning the unmodified text + Default::default() payload
matches the plain index_path behaviour.
commit_sidecar runs inside the same transaction as the
chunk inserts, so the caller’s sidecar tables (e.g.
note_metadata, note_links, note_tags) stay consistent with
documents even on crash.
pub fn purge_path(&mut self, path: impl AsRef<Path>) -> Result<usize>
pub fn search(&self, options: &SearchOptions) -> Result<Vec<SearchHit>>
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Borrow the underlying SQLite connection. Useful for crates that
extend the schema (e.g. lexa-obsidian adds note_metadata,
note_links, note_tags, note_blocks sidecar tables) and
need to run their own SQL on the same connection rather than
opening a second one (which would lock the WAL).
pub fn list_documents(&self) -> Result<Vec<Document>>
pub fn stats(&self) -> Result<IndexStats>
Auto Trait Implementations§
impl !Freeze for LexaDb
impl !RefUnwindSafe for LexaDb
impl Send for LexaDb
impl !Sync for LexaDb
impl Unpin for LexaDb
impl UnsafeUnpin for LexaDb
impl !UnwindSafe for LexaDb
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> 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