Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Public Member Functions | Protected Attributes | List of all members
Lucene.Net.Search.Function.CustomScoreProvider Class Reference

An instance of this subclass should be returned by CustomScoreQuery.GetCustomScoreProvider, if you want to modify the custom score calculation of a CustomScoreQuery. More...

Inherited by Lucene.Net.Search.Function.CustomScoreQuery.AnonymousCustomScoreProvider.

Public Member Functions

 CustomScoreProvider (IndexReader reader)
 Creates a new instance of the provider class for the given IndexReader.
 
virtual float CustomScore (int doc, float subQueryScore, float[] valSrcScores)
 
 
virtual float CustomScore (int doc, float subQueryScore, float valSrcScore)
 Compute a custom score by the subQuery score and the ValueSourceQuery score. Subclasses can override this method to modify the custom score. If your custom scoring is different than the default herein you should override at least one of the two customScore() methods. If the number of ValueSourceQueries is always < 2 it is sufficient to override this customScore() method, which is simpler. The default computation herein is a multiplication of the two scores:
 
virtual Explanation CustomExplain (int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
 Explain the custom score. Whenever overriding CustomScore(int, float, float[]), this method should also be overridden to provide the correct explanation for the part of the custom scoring.
 
virtual Explanation CustomExplain (int doc, Explanation subQueryExpl, Explanation valSrcExpl)
 Explain the custom score. Whenever overriding CustomScore(int, float, float), this method should also be overridden to provide the correct explanation for the part of the custom scoring.
 

Protected Attributes

IndexReader reader
 

Detailed Description

An instance of this subclass should be returned by CustomScoreQuery.GetCustomScoreProvider, if you want to modify the custom score calculation of a CustomScoreQuery.

Since Lucene 2.9, queries operate on each segment of an Index separately, so overriding the similar (now deprecated) methods in CustomScoreQuery is no longer suitable, as the supplied doc ID is per-segment and without knowledge of the IndexReader you cannot access the document or FieldCache.

.experimental

Since
2.9.2

Definition at line 39 of file CustomScoreProvider.cs.

Constructor & Destructor Documentation

Lucene.Net.Search.Function.CustomScoreProvider.CustomScoreProvider ( IndexReader  reader)

Creates a new instance of the provider class for the given IndexReader.

Definition at line 47 of file CustomScoreProvider.cs.

Member Function Documentation

virtual Explanation Lucene.Net.Search.Function.CustomScoreProvider.CustomExplain ( int  doc,
Explanation  subQueryExpl,
Explanation[]  valSrcExpls 
)
virtual

Explain the custom score. Whenever overriding CustomScore(int, float, float[]), this method should also be overridden to provide the correct explanation for the part of the custom scoring.

Parameters
docdoc being explained
subQueryExplexplanation for the sub-query part
valSrcExplsexplanation for the value source part
Returns
an explanation for the custom score

Definition at line 126 of file CustomScoreProvider.cs.

virtual Explanation Lucene.Net.Search.Function.CustomScoreProvider.CustomExplain ( int  doc,
Explanation  subQueryExpl,
Explanation  valSrcExpl 
)
virtual

Explain the custom score. Whenever overriding CustomScore(int, float, float), this method should also be overridden to provide the correct explanation for the part of the custom scoring.

Parameters
docdoc being explained
subQueryExplexplanation for the sub-query part
valSrcExplexplanation for the value source part
Returns
an explanation for the custom score

Definition at line 161 of file CustomScoreProvider.cs.

virtual float Lucene.Net.Search.Function.CustomScoreProvider.CustomScore ( int  doc,
float  subQueryScore,
float[]  valSrcScores 
)
virtual

  • Compute a custom score by the subQuery score and a number of ValueSourceQuery scores.

Subclasses can override this method to modify the custom score.

If your custom scoring is different than the default herein you should override at least one of the two customScore() methods. If the number of ValueSourceQueries is always < 2 it is sufficient to override the other CustomScore() method, which is simpler.

The default computation herein is a multiplication of given scores:

    ModifiedScore = valSrcScore * valSrcScores[0] * valSrcScores[1] * ...
Parameters
docid of scored doc
subQueryScorescore of that doc by the subQuery
valSrcScoresscores of that doc by the ValueSourceQuery
Returns
custom score

Definition at line 74 of file CustomScoreProvider.cs.

virtual float Lucene.Net.Search.Function.CustomScoreProvider.CustomScore ( int  doc,
float  subQueryScore,
float  valSrcScore 
)
virtual

Compute a custom score by the subQuery score and the ValueSourceQuery score. Subclasses can override this method to modify the custom score. If your custom scoring is different than the default herein you should override at least one of the two customScore() methods. If the number of ValueSourceQueries is always < 2 it is sufficient to override this customScore() method, which is simpler. The default computation herein is a multiplication of the two scores:

    ModifiedScore = subQueryScore * valSrcScore
Parameters
docid of scored doc
subQueryScorescore of that doc by the subQuery
valSrcScorescore of that doc by the ValueSourceQuery
Returns
custom score

Definition at line 111 of file CustomScoreProvider.cs.

Member Data Documentation

IndexReader Lucene.Net.Search.Function.CustomScoreProvider.reader
protected

Definition at line 42 of file CustomScoreProvider.cs.


The documentation for this class was generated from the following file: