pub struct FtsStore { /* private fields */ }Expand description
Full-text search store using Tantivy
Single connection type that supports both read and write operations. Writer is lazy-initialized on first write to avoid unnecessary locks.
Implementations§
Source§impl FtsStore
impl FtsStore
Sourcepub fn new(db_path: &Path) -> Result<Self>
pub fn new(db_path: &Path) -> Result<Self>
Create or open an FTS index at the given path.
Opens in a mode that supports both reading and writing. Writer is lazy-initialized on first write operation.
Sourcepub fn new_with_writer(db_path: &Path) -> Result<Self>
pub fn new_with_writer(db_path: &Path) -> Result<Self>
Create or open an FTS index with writer ready for indexing.
Use this when you know you’ll be writing immediately (e.g., during indexing).
For search-only or mixed workloads, use new() instead.
Sourcepub fn add_chunk(
&mut self,
chunk_id: u32,
content: &str,
path: &str,
signature: Option<&str>,
kind: &str,
) -> Result<()>
pub fn add_chunk( &mut self, chunk_id: u32, content: &str, path: &str, signature: Option<&str>, kind: &str, ) -> Result<()>
Add a chunk to the FTS index
Includes writer recovery: if the writer was killed (e.g., by a background merge thread panic), it will be recreated and the operation retried once.
Sourcepub fn delete_chunk(&mut self, chunk_id: u32) -> Result<()>
pub fn delete_chunk(&mut self, chunk_id: u32) -> Result<()>
Delete a chunk by ID
Sourcepub fn delete_by_path(&mut self, path: &str) -> Result<()>
pub fn delete_by_path(&mut self, path: &str) -> Result<()>
Delete all chunks for a file path
Sourcepub fn commit(&mut self) -> Result<()>
pub fn commit(&mut self) -> Result<()>
Commit pending changes with retry logic for Windows file locking.
If the writer was killed (background merge panic), it is recreated. Data since the last successful commit will be lost in that case, but indexing can continue rather than aborting entirely.
Sourcepub fn search(
&self,
query: &str,
limit: usize,
target_kind: Option<ChunkKind>,
) -> Result<Vec<FtsResult>>
pub fn search( &self, query: &str, limit: usize, target_kind: Option<ChunkKind>, ) -> Result<Vec<FtsResult>>
Search using BM25
If target_kind is provided, boosts results matching that ChunkKind (e.g., “class”, “function”).
Sourcepub fn search_exact(
&self,
identifier: &str,
limit: usize,
target_kind: Option<ChunkKind>,
) -> Result<Vec<FtsResult>>
pub fn search_exact( &self, identifier: &str, limit: usize, target_kind: Option<ChunkKind>, ) -> Result<Vec<FtsResult>>
Search for exact identifier matches (boosted)
Used for improving exact name matching (e.g., “BaseRestClient”, “UserService”).
If target_kind is provided, uses selective boosting:
- When both identifier AND kind are present, applies MUST constraint: items must match the identifier in the signature field AND the kind (prevents boosting ALL items of that kind)
- Otherwise, uses standard boost on the kind field
Auto Trait Implementations§
impl Freeze for FtsStore
impl !RefUnwindSafe for FtsStore
impl Send for FtsStore
impl Sync for FtsStore
impl Unpin for FtsStore
impl UnsafeUnpin for FtsStore
impl !UnwindSafe for FtsStore
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more