pub struct TextIndex { /* private fields */ }Expand description
Full-text search index backed by tantivy.
Provides BM25 scoring for text search, designed to work alongside HNSW vector search for hybrid retrieval.
Implementations§
Source§impl TextIndex
impl TextIndex
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Create or open a text index at the given path with default config.
§Example
use omendb::text::TextIndex;
let index = TextIndex::open("./text_index").unwrap();Sourcepub fn open_with_config<P: AsRef<Path>>(
path: P,
config: &TextSearchConfig,
) -> Result<Self>
pub fn open_with_config<P: AsRef<Path>>( path: P, config: &TextSearchConfig, ) -> Result<Self>
Create or open a text index with custom configuration.
§Example
use omendb::text::{TextIndex, TextSearchConfig};
let config = TextSearchConfig { writer_buffer_mb: 100 };
let index = TextIndex::open_with_config("./text_index", &config).unwrap();Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Create an in-memory text index with default config.
Sourcepub fn open_in_memory_with_config(config: &TextSearchConfig) -> Result<Self>
pub fn open_in_memory_with_config(config: &TextSearchConfig) -> Result<Self>
Create an in-memory text index with custom configuration.
Sourcepub fn index_document(&mut self, id: &str, text: &str) -> Result<()>
pub fn index_document(&mut self, id: &str, text: &str) -> Result<()>
Index a document with the given ID and text content.
If a document with this ID already exists, it will be updated.
Sourcepub fn delete_document(&mut self, id: &str) -> Result<()>
pub fn delete_document(&mut self, id: &str) -> Result<()>
Delete a document by ID.
Sourcepub fn commit(&mut self) -> Result<()>
pub fn commit(&mut self) -> Result<()>
Commit pending changes to the index.
Changes are not visible to searchers until commit is called. This also reloads the reader to see the new changes immediately.
Sourcepub fn search(
&self,
query_str: &str,
limit: usize,
) -> Result<Vec<(String, f32)>>
pub fn search( &self, query_str: &str, limit: usize, ) -> Result<Vec<(String, f32)>>
Search for documents matching the query.
Returns a vector of (id, score) tuples, sorted by score descending.
§Arguments
query_str- The search query (supports tantivy query syntax)limit- Maximum number of results to return
Sourcepub fn reader(&self) -> &IndexReader
pub fn reader(&self) -> &IndexReader
Get a reference to the index reader.
Auto Trait Implementations§
impl Freeze for TextIndex
impl !RefUnwindSafe for TextIndex
impl Send for TextIndex
impl Sync for TextIndex
impl Unpin for TextIndex
impl !UnwindSafe for TextIndex
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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
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