Table of Contents

Public classSealed IndexSearcher

Namespace
Rowles.LeanCorpus.Search.Searcher
Assembly
Rowles.LeanCorpus.dll

Holds a snapshot of segment readers and executes queries across all segments.

public sealed class IndexSearcher : IDisposable
IndexSearcher

Public constructor IndexSearcher(MMapDirectory, ISimilarity?)

Initialises a new IndexSearcher by loading the latest committed segments from the given directory.

Public constructor IndexSearcher(MMapDirectory, IndexSearcherConfig)

Initialises a new IndexSearcher by loading the latest committed segments from the given directory.

Public constructor IndexSearcher(MMapDirectory, IReadOnlyList<SegmentInfo>, ISimilarity?)

Initialises a new IndexSearcher over the given pre-built segment list (NRT or snapshot scenario).

Public constructor IndexSearcher(MMapDirectory, IReadOnlyList<SegmentInfo>, IndexSearcherConfig)

Initialises a new IndexSearcher over the given pre-built segment list with the specified configuration.

Public field t_collectorHeapCache

Public field t_docFreqTermsBuf

Public field t_fallbackCandidateIds

Public field t_fallbackInCandidate

Public field t_fallbackInClause

Public field t_fallbackInUse

Public field t_fallbackScores

Public field t_patternDocIds

Public field t_patternScores

Public field t_patternSeen

Public field t_postingsBuffer

Public property Cache

The query result cache, or null if caching is disabled.

Public property Metrics

The metrics collector for this searcher.

Public property Stats

Corpus-wide statistics computed at construction.

Public method Dispose()

Disposes all underlying segment readers.

Internal methodInternal ExecuteMoreLikeThis(MoreLikeThisQuery, int)

Public method Explain(TermQuery, int)

Explains the score computation for a specific document and query. Returns null if the document does not match the query.

Public method Explain(VectorQuery, int)

Explains the score and execution strategy for a VectorQuery against a specific document. Surfaces the chosen ANN strategy (flat scan, HNSW two-phase, brute-force filter, HNSW pre-filter, HNSW post-filter), the configured ef, and shortlist size. Returns null if the document does not exist or has no vector for the query field.

Public method GetIndexSize()

Calculates the on-disk size of the index.

Public method GetStoredFields(int)

Retrieves stored fields for a global document ID.

Public method MoreLikeThis(int, string[], int, MoreLikeThisParameters?)

Convenience API: finds documents similar to the given document. Extracts significant terms from term vectors and re-queries the index.

Public method Search(Query, int)

Executes a query and returns the top-topN scoring documents. Checks the query cache first, then falls back to the full search pipeline.

Public method Search(Query, int, SortField)

Searches with a custom sort order instead of relevance ranking. Matching documents are collected, then a heap-select picks the top-N by the requested field without performing a full sort over every match.

Public method Search(Query, int, SearchOptions)

Executes a query under the supplied SearchOptions. The top-N heap must fit within the configured result-byte budget. The deadline and cancellation token are checked at segment boundaries; on early termination the returned TopDocs has IsPartial set to true.

Public method Search(Query, int, CancellationToken)

Searches with cancellation support. Checks the token between segments and between inner sub-clauses, allowing long-running queries to be interrupted.

Public method Search(string, string, int, IAnalyser?)

Parses a query string, applies analysis, and searches.

Public method Search(string, string, int, IAnalyser?, CancellationToken)

Parses a query string and searches with cancellation support.

Public method SearchStreaming(Query, int, SearchOptions?)

Executes a query and yields matches in segment order, segment by segment. Honours Timeout, MaxResultBytes, and CancellationToken between segments. Results are not globally sorted by score: the caller receives each segment's local top-N, in segment order, with global doc IDs.

Public method SearchWithAggregations(Query, int, params AggregationRequest[])

Executes a search query and computes numeric aggregations over matching documents.

Public method SearchWithCollapse(Query, int, CollapseField)

Executes a search and collapses results so only the best document per unique field value is returned. Uses SortedDocValues for the collapse field.

Public method SearchWithFacets(Query, int, params string[])

Executes a query and returns both top-N results and facet counts for the specified fields.

Public method Suggest(string, string, int)

Returns the top-N terms with the given prefix for auto-complete / suggest, ranked by global document frequency descending.