
SegmentReader
- Namespace
- Rowles.LeanLucene.Index.Segment
- Assembly
- Rowles.LeanLucene.dll
Reads a single immutable segment from disc via MMapDirectory.
public sealed class SegmentReader : IDisposable
Constructors
SegmentReader(MMapDirectory, SegmentInfo)
Initialises a new SegmentReader for the given segment. Opens all required files and validates the segment's on-disk data.
Properties
DocBase
Gets or sets the document base offset for this reader within the global document namespace.
HasDeletions
True when this segment has no deleted documents, allowing callers to skip per-doc IsLive checks.
HasTermVectors
Whether this segment has term vector files.
HasVectors
Returns whether this segment has vector data.
Info
Gets the segment metadata for this reader.
MaxDoc
Gets the total number of documents in this segment, including deleted documents.
VectorFieldNames
Returns the field names with vector data in this segment.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
GetAllTermsForField(string)
Returns all terms for a given field.
GetDocFreq(string)
Returns the document frequency for a pre-built qualified term string.
GetDocFreq(string, string)
Returns the document frequency for a term (count only, no full decode).
GetDocFreqByQualified(string)
Returns the document frequency using a pre-built qualified term string.
GetDocIds(string)
Returns document IDs for a pre-built qualified term string.
GetDocIds(string, string)
Returns document IDs matching the given field and term.
GetFieldLength(int)
Returns an approximate field length using the first available field (for non-field-specific queries).
GetFieldLength(int, string)
Returns an approximate field length for BM25 for a specific field, derived from the stored norm.
GetFuzzyMatches(string, ReadOnlySpan<char>, int, int)
Returns terms within Levenshtein distance of queryTerm, with edit distances.
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.
GetNorm(int)
Returns the quantised norm value for a document using the first available field.
GetNorm(int, string)
Returns the quantised norm value for a document in a specific field (0..1 range).
GetNumericDocValues(string)
Returns the NumericDocValues array for a field, or null if unavailable.
GetNumericRange(string, double, double)
Returns all document IDs that have a numeric value in the given field within the specified range.
GetParentBitSet()
Returns the parent bitset for block-join indexing, or null if this segment has no block documents.
GetPositions(string, int)
Returns positional data for a pre-built qualified term string.
GetPositions(string, string, int)
Returns positional data for a term in a specific document, or null if unavailable.
GetPostingsEnum(string)
Returns a PostingsEnum cursor for the given qualified term (field\0term). Decodes the postings list once; caller must dispose.
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).
GetPostingsEnumWithPositions(string)
Returns a PostingsEnum with decoded positions for phrase queries.
GetSortedDocValues(string)
Returns the SortedDocValues array for a field, or null if unavailable.
GetStoredFields(int)
Returns all stored fields for the specified document as a read-only dictionary.
GetTermFrequency(string, int)
Returns the term frequency for a pre-built qualified term string.
GetTermFrequency(string, string, int)
Returns the term frequency for a given term in a specific document.
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.
GetTermsInRange(string, string?, string?, bool, bool)
Returns terms in lexicographic range [lower, upper] for a field.
GetTermsMatching(string, ReadOnlySpan<char>)
Returns all terms for a field matching a wildcard pattern.
GetTermsMatchingRegex(string, Regex)
Returns terms for a field matching the compiled regex.
GetTermsWithPrefix(string)
Returns all terms matching a qualified prefix.
GetVector(int)
Reads the vector for a given document from the first available vector field (legacy convenience).
GetVector(string, int)
Reads the vector for a given document on the named vector field.
IntersectAutomaton(string, IAutomaton)
Intersects the term dictionary with an automaton, returning matching terms.
IsLive(int)
Returns true if the document with the given ID has not been deleted.
ReadDocFreqAtOffset(long)
Reads docFreq directly from a known postings file offset (no dictionary lookup).
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.
TryGetNumericValue(string, int, out double)
Tries to get a numeric field value for a document from the .num index.
TryGetSortedDocValue(string, int, out string)
Tries to get a string DocValues field value for a document.