pub struct SearchEngine<K, D: TokenEmbedder = u32, T = DefaultTokenizer> { /* private fields */ }Expand description
A search engine that ranks documents with BM25. K is the type of the document id, D is the type of the token embedder and T is the type of the tokenizer.
Implementations§
Source§impl<K, D, T> SearchEngine<K, D, T>
impl<K, D, T> SearchEngine<K, D, T>
Sourcepub fn upsert(&mut self, document: impl Into<Document<K>>)
pub fn upsert(&mut self, document: impl Into<Document<K>>)
Upserts a document into the search engine. If a document with the same id already exists,
it will be replaced. Note that upserting a document will change the true value of avgdl.
The more avgdl drifts from its true value, the less accurate the BM25 scores will be.
Sourcepub fn remove(&mut self, document_id: &K)
pub fn remove(&mut self, document_id: &K)
Removes a document from the search engine if it exists.
Sourcepub fn get(&self, document_id: &K) -> Option<Document<K>>
pub fn get(&self, document_id: &K) -> Option<Document<K>>
Gets the contents of a document by its id.
Trait Implementations§
Auto Trait Implementations§
impl<K, D, T> Freeze for SearchEngine<K, D, T>where
T: Freeze,
impl<K, D, T> RefUnwindSafe for SearchEngine<K, D, T>where
T: RefUnwindSafe,
D: RefUnwindSafe,
K: RefUnwindSafe,
<D as TokenEmbedder>::EmbeddingSpace: RefUnwindSafe,
impl<K, D, T> Send for SearchEngine<K, D, T>
impl<K, D, T> Sync for SearchEngine<K, D, T>
impl<K, D, T> Unpin for SearchEngine<K, D, T>
impl<K, D, T> UnwindSafe for SearchEngine<K, D, T>where
T: UnwindSafe,
K: UnwindSafe,
D: UnwindSafe,
<D as TokenEmbedder>::EmbeddingSpace: UnwindSafe,
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
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>
Converts
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>
Converts
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