pub struct Index { /* private fields */ }Expand description
A lazily-maintained fst-segment index rooted at a directory (.ct/okf/).
Implementations§
Source§impl Index
impl Index
Sourcepub fn open(dir: &Path) -> Result<Index, String>
pub fn open(dir: &Path) -> Result<Index, String>
Open the index at dir, loading manifest.json if present (an absent or
unreadable manifest yields an empty index). The directory is created on
the first Index::save.
Sourcepub fn segment_count(&self) -> usize
pub fn segment_count(&self) -> usize
Number of live segments.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Number of tombstoned documents awaiting condense.
Sourcepub fn pending(&self, current: &[FileStat]) -> (usize, usize, usize)
pub fn pending(&self, current: &[FileStat]) -> (usize, usize, usize)
How many of current are new / changed / removed relative to the
manifest — a read-only staleness probe for index status that mutates
nothing (the same diff update would act on).
Sourcepub fn search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SearchHit>, String>
pub fn search( &self, query: &str, limit: usize, ) -> Result<Vec<SearchHit>, String>
Search the index, returning up to limit hits ranked by a tf-idf score.
Reads every live segment; tombstoned documents are filtered out.
Sourcepub fn condense(&mut self) -> Result<bool, String>
pub fn condense(&mut self) -> Result<bool, String>
Merge every segment into one, dropping tombstoned documents and their postings, then delete the old segment files. Reclaims space without re-reading any source file. A no-op when there is nothing to gain (≤1 segment and no tombstones).