You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Michael McCandless <lu...@mikemccandless.com> on 2010/01/04 12:54:29 UTC
Re: Bug on doc parameter in CustomScoreQuery.customScore()
Alas, this is a bug in CustomScoreQuery. I've opened this:
https://issues.apache.org/jira/browse/LUCENE-2190
With Lucene 2.9, we now search one segment at a time. So the rollback
to 0 that you're seeing is in fact due to a new segment being
searched. We need to fix CustomScoreQuery to notify the subclass when
it switches to a new segment.
Mike
On Mon, Dec 28, 2009 at 9:21 PM, Paul chez Jamespot
<pa...@jamespot.com> wrote:
> 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
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org