Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 70449 invoked from network); 4 Jan 2010 11:55:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Jan 2010 11:55:05 -0000 Received: (qmail 19041 invoked by uid 500); 4 Jan 2010 11:54:59 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 18965 invoked by uid 500); 4 Jan 2010 11:54:59 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 18738 invoked by uid 99); 4 Jan 2010 11:54:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jan 2010 11:54:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [209.85.210.193] (HELO mail-yx0-f193.google.com) (209.85.210.193) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jan 2010 11:54:51 +0000 Received: by yxe31 with SMTP id 31so14688530yxe.21 for ; Mon, 04 Jan 2010 03:54:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.150.78.1 with SMTP id a1mr35009758ybb.39.1262606069341; Mon, 04 Jan 2010 03:54:29 -0800 (PST) In-Reply-To: <5271079120438103509@unknownmsgid> References: <5271079120438103509@unknownmsgid> Date: Mon, 4 Jan 2010 06:54:29 -0500 Message-ID: <9ac0c6aa1001040354t3cc69636g2dee0a9e3619d1b2@mail.gmail.com> Subject: Re: Bug on doc parameter in CustomScoreQuery.customScore() From: Michael McCandless To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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 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 fiel= d > containing the timestamp (as long) > > And I use the FieldCache to access the timestamp value. > > > > > > public class DateScoreQuery extends CustomScoreQuery { > > =A0 =A0 =A0private IndexReader ir; > > =A0 =A0 =A0private String fld; > > > > =A0 =A0 =A0public DateScoreQuery(Query subQuery, =A0IndexReader indexRead= er, String > fieldTimeStamp) { > > =A0 =A0 =A0 =A0 =A0 =A0super(subQuery); > > =A0 =A0 =A0 =A0 =A0 =A0ir =3D indexReader; > > =A0 =A0 =A0 =A0 =A0 =A0fld=3DfieldTimeStamp; > > =A0 =A0 =A0} > > > > =A0 =A0 =A0public float customScore(int doc, float subQueryScore, float > valSrcScore) { > > > > =A0 =A0 =A0 =A0 =A0 =A0long[] timeStamps; > > =A0 =A0 =A0 =A0 =A0 =A0try { > > timeStamps =3D FieldCache.DEFAULT.getLongs(ir, fld); > > }catch(IOException e){.} > > =A0 =A0 =A0 =A0 =A0 =A0long docTimeStamp =3D timeStamps[doc]; > > =A0 =A0 =A0 =A0 =A0 =A0return subQueryScore * timeRatio(docTimeStamp); > > =A0 =A0 =A0 =A0} > > . > > } > > > > When the index is not optimized, customScore(doc) is never called for hig= h > values doc. > > Instead, when I debug, I can see doc values looping =A0through 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