Home » lucene-3.0.1-src » org.apache » lucene » search » function » [javadoc | source]
org.apache.lucene.search.function
public class: CustomScoreProvider [javadoc | source]
java.lang.Object
   org.apache.lucene.search.function.CustomScoreProvider
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 .

Field Summary
protected final  IndexReader reader     
Constructor:
 public CustomScoreProvider(IndexReader reader) 
    Creates a new instance of the provider class for the given IndexReader .
Method from org.apache.lucene.search.function.CustomScoreProvider Summary:
customExplain,   customExplain,   customScore,   customScore
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.search.function.CustomScoreProvider Detail:
 public Explanation customExplain(int doc,
    Explanation subQueryExpl,
    Explanation[] valSrcExpls) throws IOException 
    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.
 public Explanation customExplain(int doc,
    Explanation subQueryExpl,
    Explanation valSrcExpl) throws IOException 
    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.
 public float customScore(int doc,
    float subQueryScore,
    float[] valSrcScores) throws IOException 
    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] * ...
    
 public float customScore(int doc,
    float subQueryScore,
    float valSrcScore) throws IOException 
    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