Table of Contents

Public classSealed SegmentReader

Namespace
Rowles.LeanLucene.Index.Segment
Assembly
Rowles.LeanLucene.dll

Reads a single immutable segment from disc via MMapDirectory.

public sealed class SegmentReader : IDisposable
SegmentReader

Constructors

Public constructor SegmentReader(MMapDirectory, SegmentInfo)

Initialises a new SegmentReader for the given segment. Opens all required files and validates the segment's on-disk data.

Properties

Public property DocBase

Gets or sets the document base offset for this reader within the global document namespace.

Public propertyRead-only HasDeletions

True when this segment has no deleted documents, allowing callers to skip per-doc IsLive checks.

Public propertyRead-only HasTermVectors

Whether this segment has term vector files.

Public propertyRead-only HasVectors

Returns whether this segment has vector data.

Public propertyRead-only Info

Gets the segment metadata for this reader.

Public propertyRead-only MaxDoc

Gets the total number of documents in this segment, including deleted documents.

Internal propertyRead-onlyInternal TermOffsetCacheCount
Internal propertyRead-onlyInternal TermOffsetCacheHits
Public propertyRead-only VectorFieldNames

Returns the field names with vector data in this segment.

Methods

Public method Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Public method GetAllTermsForField(string)

Returns all terms for a given field.

Internal methodInternal GetDocFreq(string)

Returns the document frequency for a pre-built qualified term string.

Public method GetDocFreq(string, string)

Returns the document frequency for a term (count only, no full decode).

Public method GetDocFreqByQualified(string)

Returns the document frequency using a pre-built qualified term string.

Internal methodInternal GetDocIds(string)

Returns document IDs for a pre-built qualified term string.

Public method GetDocIds(string, string)

Returns document IDs matching the given field and term.

Public method GetFieldLength(int)

Returns an approximate field length using the first available field (for non-field-specific queries).

Public method GetFieldLength(int, string)

Returns an approximate field length for BM25 for a specific field, derived from the stored norm.

Public method GetFuzzyMatches(string, ReadOnlySpan<char>, int, int)

Returns terms within Levenshtein distance of queryTerm, with edit distances.

Internal methodInternal GetHnswGraph(string)

Returns the (lazy-loaded) HNSW graph for the given vector field, or null if no graph exists. Thread-safe; the first caller materialises the graph and subsequent callers reuse it.

Public method GetNorm(int)

Returns the quantised norm value for a document using the first available field.

Public method GetNorm(int, string)

Returns the quantised norm value for a document in a specific field (0..1 range).

Public method GetNumericDocValues(string)

Returns the NumericDocValues array for a field, or null if unavailable.

Public method GetNumericRange(string, double, double)

Returns all document IDs that have a numeric value in the given field within the specified range.

Internal methodInternal GetParentBitSet()

Returns the parent bitset for block-join indexing, or null if this segment has no block documents.

Internal methodInternal GetPositions(string, int)

Returns positional data for a pre-built qualified term string.

Public method GetPositions(string, string, int)

Returns positional data for a term in a specific document, or null if unavailable.

Public method GetPostingsEnum(string)

Returns a PostingsEnum cursor for the given qualified term (field\0term). Decodes the postings list once; caller must dispose.

Public method GetPostingsEnumAtOffset(long)

Returns a PostingsEnum at a known postings offset, skipping the dictionary lookup. Use when the offset was already obtained from a term scan (e.g. prefix/wildcard).

Public method GetPostingsEnumWithPositions(string)

Returns a PostingsEnum with decoded positions for phrase queries.

Public method GetSortedDocValues(string)

Returns the SortedDocValues array for a field, or null if unavailable.

Public method GetStoredFields(int)

Returns all stored fields for the specified document as a read-only dictionary.

Internal methodInternal GetTermFrequency(string, int)

Returns the term frequency for a pre-built qualified term string.

Public method GetTermFrequency(string, string, int)

Returns the term frequency for a given term in a specific document.

Public method GetTermVectors(int)

Returns term vectors for a document, or null if term vectors are not stored for this segment. Lazily opens the .tvd/.tvx files on first access.

Public method GetTermsInRange(string, string?, string?, bool, bool)

Returns terms in lexicographic range [lower, upper] for a field.

Public method GetTermsMatching(string, ReadOnlySpan<char>)

Returns all terms for a field matching a wildcard pattern.

Public method GetTermsMatchingRegex(string, Regex)

Returns terms for a field matching the compiled regex.

Public method GetTermsWithPrefix(string)

Returns all terms matching a qualified prefix.

Public method GetVector(int)

Reads the vector for a given document from the first available vector field (legacy convenience).

Public method GetVector(string, int)

Reads the vector for a given document on the named vector field.

Public method IntersectAutomaton(string, IAutomaton)

Intersects the term dictionary with an automaton, returning matching terms.

Public method IsLive(int)

Returns true if the document with the given ID has not been deleted.

Internal methodInternal ReadDocFreqAtOffset(long)

Reads docFreq directly from a known postings file offset (no dictionary lookup).

Public method TryGetFieldLengths(string, out int[]?)

Retrieves the raw field-length array for a given field, allowing callers to resolve the array once and index by docId directly in tight loops.

Public method TryGetNumericValue(string, int, out double)

Tries to get a numeric field value for a document from the .num index.

Public method TryGetSortedDocValue(string, int, out string)

Tries to get a string DocValues field value for a document.