Class PerFieldSimilarityWrapper
Provides the ability to use a different Similarity for different fields.
Subclasses should implement Get(string) to return an appropriate Similarity (for example, using field-specific parameter values) for the field.Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Search.Similarities
Assembly: Lucene.Net.dll
Syntax
public abstract class PerFieldSimilarityWrapper : Similarity
Constructors
PerFieldSimilarityWrapper()
Sole constructor. (For invocation by subclass constructors, typically implicit.)
Declaration
protected PerFieldSimilarityWrapper()
Methods
ComputeNorm(FieldInvertState)
Computes the normalization value for a field, given the accumulated state of term processing for this field (see FieldInvertState).
Matches in longer fields are less precise, so implementations of this method usually set smaller values whenstate.Length
is large,
and larger values when state.Length
is small.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public override sealed long ComputeNorm(FieldInvertState state)
Parameters
Type | Name | Description |
---|---|---|
FieldInvertState | state | current processing state for this field |
Returns
Type | Description |
---|---|
long | computed norm value |
Overrides
ComputeWeight(float, CollectionStatistics, params TermStatistics[])
Compute any collection-level weight (e.g. IDF, average document length, etc) needed for scoring a query.
Declaration
public override sealed Similarity.SimWeight ComputeWeight(float queryBoost, CollectionStatistics collectionStats, params TermStatistics[] termStats)
Parameters
Type | Name | Description |
---|---|---|
float | queryBoost | the query-time boost. |
CollectionStatistics | collectionStats | collection-level statistics, such as the number of tokens in the collection. |
TermStatistics[] | termStats | term-level statistics, such as the document frequency of a term across the collection. |
Returns
Type | Description |
---|---|
Similarity.SimWeight | Similarity.SimWeight object with the information this Similarity needs to score a query. |
Overrides
Get(string)
Returns a Similarity for scoring a field.
Declaration
public abstract Similarity Get(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name |
Returns
Type | Description |
---|---|
Similarity |
GetSimScorer(SimWeight, AtomicReaderContext)
Creates a new Similarity.SimScorer to score matching documents from a segment of the inverted index.
Declaration
public override sealed Similarity.SimScorer GetSimScorer(Similarity.SimWeight weight, AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
Similarity.SimWeight | weight | collection information from ComputeWeight(float, CollectionStatistics, params TermStatistics[]) |
AtomicReaderContext | context | segment of the inverted index to be scored. |
Returns
Type | Description |
---|---|
Similarity.SimScorer | Sloppy Similarity.SimScorer for scoring documents across |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | if there is a low-level I/O error |