pub struct TermIndex { /* private fields */ }Expand description
An inverted index mapping tokenized terms to posting lists (sorted node ID arrays).
Implementations§
Source§impl TermIndex
impl TermIndex
Sourcepub fn build(graph: &MemoryGraph, tokenizer: &Tokenizer) -> Self
pub fn build(graph: &MemoryGraph, tokenizer: &Tokenizer) -> Self
Build the index from all node contents in the graph.
Sourcepub fn get(&self, term: &str) -> &[(u64, u32)]
pub fn get(&self, term: &str) -> &[(u64, u32)]
Look up a term. Returns (node_id, term_frequency) pairs.
Sourcepub fn doc_frequency(&self, term: &str) -> usize
pub fn doc_frequency(&self, term: &str) -> usize
Number of nodes containing a term (document frequency).
Sourcepub fn avg_doc_length(&self) -> f32
pub fn avg_doc_length(&self) -> f32
Average document length.
Sourcepub fn term_count(&self) -> usize
pub fn term_count(&self) -> usize
Number of unique terms.
Sourcepub fn add_node(&mut self, event: &CognitiveEvent)
pub fn add_node(&mut self, event: &CognitiveEvent)
Add a single node to the index incrementally.
Sourcepub fn remove_node(&mut self, id: u64)
pub fn remove_node(&mut self, id: u64)
Remove a node from the index.
Sourcepub fn rebuild(&mut self, graph: &MemoryGraph)
pub fn rebuild(&mut self, graph: &MemoryGraph)
Rebuild the index from a graph.
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Deserialize a term index from bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TermIndex
impl RefUnwindSafe for TermIndex
impl Send for TermIndex
impl Sync for TermIndex
impl Unpin for TermIndex
impl UnsafeUnpin for TermIndex
impl UnwindSafe for TermIndex
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