Class Weight
Expert: Calculate query weights and build query scorers.
The purpose of Weight is to ensure searching does not modify a Query, so that a Query instance can be reused.
IndexSearcher dependent state of the query should reside in the Weight.
AtomicReader dependent state should reside in the Scorer.
Since Weight creates Scorer instances for a given AtomicReaderContext (GetScorer(AtomicReaderContext, IBits)) callers must maintain the relationship between the searcher's top-level IndexReaderContext and the context used to create a Scorer.
A Weight is used in the following way:
- A Weight is constructed by a top-level query, given a IndexSearcher (CreateWeight(IndexSearcher)).
- The GetValueForNormalization() method is called on the Weight to compute the query normalization factor QueryNorm(Single) of the query clauses contained in the query.
- The query normalization factor is passed to Normalize(Single, Single). At this point the weighting is complete.
- A Scorer is constructed by GetScorer(AtomicReaderContext, IBits).
@since 2.9
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class Weight : object
Properties
Name | Description |
---|---|
Query | The query that this concerns. |
ScoresDocsOutOfOrder | Returns true if this implementation scores docs only out of order. This method is used in conjunction with ICollector's AcceptsDocsOutOfOrder and GetBulkScorer(AtomicReaderContext, Boolean, IBits) to create a matching Scorer instance for a given ICollector, or vice versa.
NOTE: the default implementation returns |
Methods
Name | Description |
---|---|
Explain(AtomicReaderContext, Int32) | An explanation of the score computation for the named document. |
GetBulkScorer(AtomicReaderContext, Boolean, IBits) | Optional method, to return a BulkScorer to score the query and send hits to a ICollector. Only queries that have a different top-level approach need to override this; the default implementation pulls a normal Scorer and iterates and collects the resulting hits. |
GetScorer(AtomicReaderContext, IBits) | Returns a Scorer which scores documents in/out-of order according
to
NOTE: even if
NOTE: |
GetValueForNormalization() | The value for normalization of contained query clauses (e.g. sum of squared weights). |
Normalize(Single, Single) | Assigns the query normalization factor and boost from parent queries to this. |