Hello,
I'm trying to use the doc parameter to build a customScore, but the 'doc'
value seems to be different from the global 'docId' when the index is not
optimized.
Basically, I create a DateScoreQuery passing the IndexReader and the field
containing the timestamp (as long)
And I use the FieldCache to access the timestamp value.
public class DateScoreQuery extends CustomScoreQuery {
private IndexReader ir;
private String fld;
public DateScoreQuery(Query subQuery, IndexReader indexReader, String
fieldTimeStamp) {
super(subQuery);
ir = indexReader;
fld=fieldTimeStamp;
}
public float customScore(int doc, float subQueryScore, float
valSrcScore) {
long[] timeStamps;
try {
timeStamps = FieldCache.DEFAULT.getLongs(ir, fld);
}catch(IOException e){.}
long docTimeStamp = timeStamps[doc];
return subQueryScore * timeRatio(docTimeStamp);
}
.
}
When the index is not optimized, customScore(doc) is never called for high
values doc.
Instead, when I debug, I can see doc values looping through cycles.
After index optimization, returned values seemed to be correct.
Paul Giraudon