pub struct LexicalIndex { /* private fields */ }Expand description
The store-wide lexical index across every segment.
§Segments here are SEALED
push_segment encodes the active segment into the
persisted posting layout and keeps only that. There is therefore exactly
one scoring path in the engine — over bytes — rather than an in-memory
one that ships and a persisted one that is only ever tested.
Implementations§
Source§impl LexicalIndex
impl LexicalIndex
Sourcepub fn push_segment(&mut self, segment: SegmentIndex) -> Result<(), IndexError>
pub fn push_segment(&mut self, segment: SegmentIndex) -> Result<(), IndexError>
Seals one active segment and appends it.
§Errors
Returns IndexError::Postings when the encoder rejects the
segment’s geometry or refuses to read back what it just wrote. Both
are broken-writer conditions, and they surface here rather than
becoming a decode fault inside a later query.
Sourcepub fn push_sealed(&mut self, segment: SealedSegment)
pub fn push_sealed(&mut self, segment: SealedSegment)
Appends an already-sealed segment.
Sourcepub fn push_sealed_with_live_rows(
&mut self,
segment: SealedSegment,
live_rows: &DocBitmap,
) -> Result<(), IndexError>
pub fn push_sealed_with_live_rows( &mut self, segment: SealedSegment, live_rows: &DocBitmap, ) -> Result<(), IndexError>
Appends an already-sealed segment with exact live-row counters.
The row set is the segment tombstone state’s live bitmap, not a query filter. Capturing it here keeps BM25 corpus statistics independent of later metadata allow-lists while avoiding any posting-list rewrite.
§Errors
Returns IndexError::LiveRowOutOfRange when the tombstone state
names a row outside the sealed segment, or
IndexError::LiveLengthMissing when a sealed length counter violates
its dense-row invariant.
Sourcepub fn segments(&self) -> &[Arc<SealedSegment>]
pub fn segments(&self) -> &[Arc<SealedSegment>]
Returns the segments in seal order.
Sourcepub fn terms(&self) -> impl Iterator<Item = &[u8]>
pub fn terms(&self) -> impl Iterator<Item = &[u8]>
Iterates the analyzed vocabulary of every segment.
Terms may repeat across segments; callers that expand a structured query must impose their own deterministic de-duplication.
Sourcepub fn document_count(&self) -> u64
pub fn document_count(&self) -> u64
Returns the store-wide document count.
Sourcepub fn total_tokens(&self) -> u64
pub fn total_tokens(&self) -> u64
Returns the store-wide analyzed token count.
Sourcepub fn corpus_stats(&self) -> Result<CorpusStats, IndexError>
pub fn corpus_stats(&self) -> Result<CorpusStats, IndexError>
Returns the store-wide corpus statistics.
This is the ONLY source of N and avgdl for scoring. There is
deliberately no per-segment equivalent.
§Errors
Returns IndexError::Stats when the index holds no documents or
no tokens, because avgdl is undefined then.
Sourcepub fn document_frequency(&self, term: &[u8], fields: &[FieldId]) -> u32
pub fn document_frequency(&self, term: &[u8], fields: &[FieldId]) -> u32
Returns the store-wide document frequency of one term.
Summed across every segment and every requested field. A document
containing the term in two fields counts once, which is what makes
this a document frequency rather than a posting count. Segments
without tombstones answer from their sealed dictionary.
Segments with tombstones decode document identifiers and count only
rows in the same live bitmap used for N and avgdl.