lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Bug on doc parameter in CustomScoreQuery.customScore()
Date Mon, 04 Jan 2010 11:54:29 GMT
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
<paul.giraudon@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


Mime
View raw message