Trait elipdotter::index::Provider
source · pub trait Provider<'a> {
type DocumentIter: Iterator<Item = Id> + ExactSizeIterator + 'a;
type WordIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a;
type WordFilteredIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a;
// Required methods
fn insert_word(&mut self, word: impl AsRef<str>, document: Id, index: usize);
fn remove_document(&mut self, document: Id);
fn contains_word(&self, word: impl AsRef<str>, document: Id) -> bool;
fn documents_with_word(
&'a self,
word: impl AsRef<str>
) -> Option<Self::DocumentIter>;
fn size(&self) -> usize;
fn word_count_upper_limit(&self) -> usize;
fn word_count_limit(&self) -> usize;
fn words(&'a self) -> Self::WordIter;
fn words_starting_with(&'a self, c: char) -> Self::WordFilteredIter;
fn word_proximity_threshold(&self) -> f32;
fn word_proximity_algorithm(&self) -> Algorithm;
// Provided method
fn digest_document(&mut self, id: Id, content: &str) { ... }
}
Expand description
Allows to insert words and remove occurrences from documents.
Required Associated Types§
type DocumentIter: Iterator<Item = Id> + ExactSizeIterator + 'a
type WordIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a
type WordFilteredIter: Iterator<Item = &'a Arc<Alphanumeral<StrPtr>>> + 'a
Required Methods§
sourcefn insert_word(&mut self, word: impl AsRef<str>, document: Id, index: usize)
fn insert_word(&mut self, word: impl AsRef<str>, document: Id, index: usize)
The implementation should convert word
to lower-case and remove any hyphen -
.
Alphanumeral
can be used for this purpose.
sourcefn remove_document(&mut self, document: Id)
fn remove_document(&mut self, document: Id)
Removes all registered occurrences of document
from all words.
sourcefn contains_word(&self, word: impl AsRef<str>, document: Id) -> bool
fn contains_word(&self, word: impl AsRef<str>, document: Id) -> bool
If document
contains at least one occurrence of word
.
fn documents_with_word( &'a self, word: impl AsRef<str> ) -> Option<Self::DocumentIter>
sourcefn size(&self) -> usize
fn size(&self) -> usize
Estimate of the number of bytes this index uses in memory, specifically the heap.
This assumes you’re on a 64-bit architecture. Else, you can expect the size to be half, as most of what’s stored in an index is pointers to data.
This should not be relied on. Rather, it’s a hint.
fn word_count_upper_limit(&self) -> usize
sourcefn word_count_limit(&self) -> usize
fn word_count_limit(&self) -> usize
The limit of Self::word_count_upper_limit
where Self::words_starting_with
is used
instead of Self::words
.
fn words(&'a self) -> Self::WordIter
fn words_starting_with(&'a self, c: char) -> Self::WordFilteredIter
fn word_proximity_threshold(&self) -> f32
fn word_proximity_algorithm(&self) -> Algorithm
Provided Methods§
sourcefn digest_document(&mut self, id: Id, content: &str)
fn digest_document(&mut self, id: Id, content: &str)
Only adds words which are alphanumeric.