|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.function.CustomScoreProvider
public class CustomScoreProvider
An instance of this subclass should be returned by
CustomScoreQuery.getCustomScoreProvider(org.apache.lucene.index.IndexReader)
, 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 the protected reader
field can be used to resolve doc IDs,
as the supplied doc
ID is per-segment and without knowledge
of the IndexReader you cannot access the document or FieldCache
.
Field Summary | |
---|---|
protected IndexReader |
reader
|
Constructor Summary | |
---|---|
CustomScoreProvider(IndexReader reader)
Creates a new instance of the provider class for the given IndexReader . |
Method Summary | |
---|---|
Explanation |
customExplain(int doc,
Explanation subQueryExpl,
Explanation valSrcExpl)
Explain the custom score. |
Explanation |
customExplain(int doc,
Explanation subQueryExpl,
Explanation[] valSrcExpls)
Explain the custom score. |
float |
customScore(int doc,
float subQueryScore,
float valSrcScore)
Compute a custom score by the subQuery score and the ValueSourceQuery score. |
float |
customScore(int doc,
float subQueryScore,
float[] valSrcScores)
Compute a custom score by the subQuery score and a number of ValueSourceQuery scores. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final IndexReader reader
Constructor Detail |
---|
public CustomScoreProvider(IndexReader reader)
IndexReader
.
Method Detail |
---|
public float customScore(int doc, float subQueryScore, float[] valSrcScores) throws IOException
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] * ...
doc
- id of scored doc.subQueryScore
- score of that doc by the subQuery.valSrcScores
- scores of that doc by the ValueSourceQuery.
IOException
public float customScore(int doc, float subQueryScore, float valSrcScore) throws IOException
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
doc
- id of scored doc.subQueryScore
- score of that doc by the subQuery.valSrcScore
- score of that doc by the ValueSourceQuery.
IOException
public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls) throws IOException
customScore(int, float, float[])
,
this method should also be overridden to provide the correct explanation
for the part of the custom scoring.
doc
- doc being explained.subQueryExpl
- explanation for the sub-query part.valSrcExpls
- explanation for the value source part.
IOException
public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl) throws IOException
customScore(int, float, float)
,
this method should also be overridden to provide the correct explanation
for the part of the custom scoring.
doc
- doc being explained.subQueryExpl
- explanation for the sub-query part.valSrcExpl
- explanation for the value source part.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |