Section navigation

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
Inheritance
IndexSearcher
Implements

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 property Cache

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

Public property CommitGeneration

The committed generation represented by this immutable searcher snapshot.

Public property Metrics

The metrics collector for this searcher.

Public property Stats

Corpus-wide statistics computed at construction.

Public method CaptureSortValues(ScoreDoc, IReadOnlyList<SortField>)

Captures the typed sort values for a result boundary.

Public method Count(Query)

Returns the total number of documents matching the query without materialising a scored heap. Uses a zero-allocation count-only collector.

Public method Dispose()

Disposes all underlying segment readers.

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 GetOrdinalMap(string, bool)

Builds an immutable global ordinal map for a sorted DocValues field across this searcher's segment snapshots.

Public method GetStoredBinaryFields(int)

Retrieves stored binary fields for a global document ID.

Public method GetStoredBinaryFields(int, ISet<string>?)

Retrieves stored binary fields for a global document ID, optionally filtering to the given set of field names. When fieldsToLoad is null, all fields are returned.

Public method GetStoredFields(int)

Retrieves stored fields for a global document ID.

Public method GetStoredFields(int, ISet<string>?)

Retrieves stored fields for a global document ID, optionally filtering to the given set of field names. When fieldsToLoad is null, all fields are returned.

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, ICollector)

Executes a query and collects results through the provided ICollector. When collector is a CountCollector, this uses a zero-allocation count-only path that avoids materialising a scored heap.

Public method Search(Query, SearchOptions)

Executes a query and returns results as an IEnumerable<T>. When StreamResults is true, results are yielded per-segment without building a global top-N heap. When false, results are materialised from a global top-N search and then yielded.

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, SortField, SearchOptions)

Searches with a custom sort order and resource controls. Honours Timeout, CancellationToken, and MaxResultBytes.

Public method Search(Query, int, params SortField[])

Searches using an ordered list of sort fields.

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, IReadOnlyList<SortField>, SearchOptions)

Searches using an ordered list of sort fields and resource controls.

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(RankingSearchRequest)

Executes an immutable ranking profile, its bounded pipeline, and its matching rules. Profile similarities must match this searcher's immutable scoring configuration.

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 SearchAfter(ScoreDoc, Query, int, params SortField[])

Returns the next page after a result from the same searcher snapshot.

Public method SearchAfter(IReadOnlyList<SearchAfterValue>, Query, int, IReadOnlyList<SortField>)

Returns the next page after explicit typed sort values.

Public method SearchAsync(Query, SearchOptions, CancellationToken)

Executes a query asynchronously and yields matches in segment order. Honours Timeout, MaxResultBytes, and both cancellationToken and CancellationToken. Results are not globally sorted by score.

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.

Public method Suggest(string, string, int, IAnalyser, Query?)

Analyses the input and returns prefix completions, optionally restricted to documents matching a context query.

Public method SuggestNext(string, string, int, IAnalyser)

Returns phrase-context completions for analysed free text.