
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
IndexSearcher(MMapDirectory, ISimilarity?)
Initialises a new IndexSearcher by loading the latest committed segments from the given directory.
IndexSearcher(MMapDirectory, IndexSearcherConfig)
Initialises a new IndexSearcher by loading the latest committed segments from the given directory.
IndexSearcher(MMapDirectory, IReadOnlyList<SegmentInfo>, ISimilarity?)
Initialises a new IndexSearcher over the given pre-built segment list (NRT or snapshot scenario).
IndexSearcher(MMapDirectory, IReadOnlyList<SegmentInfo>, IndexSearcherConfig)
Initialises a new IndexSearcher over the given pre-built segment list with the specified configuration.
Cache
The query result cache, or null if caching is disabled.
CommitGeneration
The committed generation represented by this immutable searcher snapshot.
Metrics
The metrics collector for this searcher.
Stats
Corpus-wide statistics computed at construction.
CaptureSortValues(ScoreDoc, IReadOnlyList<SortField>)
Captures the typed sort values for a result boundary.
Count(Query)
Returns the total number of documents matching the query without materialising a scored heap. Uses a zero-allocation count-only collector.
Dispose()
Disposes all underlying segment readers.
Explain(TermQuery, int)
Explains the score computation for a specific document and query. Returns null if the document does not match the query.
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.
GetIndexSize()
Calculates the on-disk size of the index.
GetOrdinalMap(string, bool)
Builds an immutable global ordinal map for a sorted DocValues field across this searcher's segment snapshots.
GetStoredBinaryFields(int)
Retrieves stored binary fields for a global document ID.
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.
GetStoredFields(int)
Retrieves stored fields for a global document ID.
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.
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.
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.
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.
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.
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.
Search(Query, int, SortField, SearchOptions)
Searches with a custom sort order and resource controls. Honours Timeout, CancellationToken, and MaxResultBytes.
Search(Query, int, params SortField[])
Searches using an ordered list of sort fields.
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.
Search(Query, int, IReadOnlyList<SortField>, SearchOptions)
Searches using an ordered list of sort fields and resource controls.
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.
Search(RankingSearchRequest)
Executes an immutable ranking profile, its bounded pipeline, and its matching rules. Profile similarities must match this searcher's immutable scoring configuration.
Search(string, string, int, IAnalyser?)
Parses a query string, applies analysis, and searches.
Search(string, string, int, IAnalyser?, CancellationToken)
Parses a query string and searches with cancellation support.
SearchAfter(ScoreDoc, Query, int, params SortField[])
Returns the next page after a result from the same searcher snapshot.
SearchAfter(IReadOnlyList<SearchAfterValue>, Query, int, IReadOnlyList<SortField>)
Returns the next page after explicit typed sort values.
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.
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.
SearchWithAggregations(Query, int, params AggregationRequest[])
Executes a search query and computes numeric aggregations over matching documents.
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.
SearchWithFacets(Query, int, params string[])
Executes a query and returns both top-N results and facet counts for the specified fields.
Suggest(string, string, int)
Returns the top-N terms with the given prefix for auto-complete / suggest, ranked by global document frequency descending.
Suggest(string, string, int, IAnalyser, Query?)
Analyses the input and returns prefix completions, optionally restricted to documents matching a context query.
SuggestNext(string, string, int, IAnalyser)
Returns phrase-context completions for analysed free text.