pub struct InvertedIndex { /* private fields */ }Expand description
Inverted index mapping terms to file handles for O(1) search
Implementations§
Source§impl InvertedIndex
impl InvertedIndex
Sourcepub fn build_from_content<P: AsRef<Path>>(
file_contents: HashMap<u32, String>,
output_fst_path: P,
output_json_path: P,
) -> Result<Self>
pub fn build_from_content<P: AsRef<Path>>( file_contents: HashMap<u32, String>, output_fst_path: P, output_json_path: P, ) -> Result<Self>
Build inverted index from file contents
Sourcepub fn load_from_files<P: AsRef<Path>>(
fst_path: P,
json_path: P,
) -> Result<Self>
pub fn load_from_files<P: AsRef<Path>>( fst_path: P, json_path: P, ) -> Result<Self>
Load existing inverted index from files
Sourcepub fn find_files_with_term(&self, term: &str) -> HashSet<u32>
pub fn find_files_with_term(&self, term: &str) -> HashSet<u32>
Find all file handles containing a term (O(1) lookup!)
Sourcepub fn find_files_with_all_terms(&self, terms: &[&str]) -> HashSet<u32>
pub fn find_files_with_all_terms(&self, terms: &[&str]) -> HashSet<u32>
Find files containing all terms (AND query)
Sourcepub fn find_files_with_any_terms(&self, terms: &[&str]) -> HashSet<u32>
pub fn find_files_with_any_terms(&self, terms: &[&str]) -> HashSet<u32>
Find files containing any terms (OR query)
Sourcepub fn contains_term(&self, term: &str) -> bool
pub fn contains_term(&self, term: &str) -> bool
Check if a term exists in the index
Sourcepub fn term_frequency(&self, term: &str) -> usize
pub fn term_frequency(&self, term: &str) -> usize
Get number of files containing a term
Sourcepub fn term_count(&self) -> usize
pub fn term_count(&self) -> usize
Get total number of unique terms
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InvertedIndex
impl RefUnwindSafe for InvertedIndex
impl Send for InvertedIndex
impl Sync for InvertedIndex
impl Unpin for InvertedIndex
impl UnwindSafe for InvertedIndex
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