Return-Path: X-Original-To: apmail-lucene-dev-archive@www.apache.org Delivered-To: apmail-lucene-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4258510B81 for ; Fri, 20 Sep 2013 15:39:55 +0000 (UTC) Received: (qmail 39913 invoked by uid 500); 20 Sep 2013 15:39:52 -0000 Delivered-To: apmail-lucene-dev-archive@lucene.apache.org Received: (qmail 39664 invoked by uid 500); 20 Sep 2013 15:39:52 -0000 Mailing-List: contact dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list dev@lucene.apache.org Received: (qmail 39649 invoked by uid 99); 20 Sep 2013 15:39:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 15:39:52 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of serera@gmail.com designates 209.85.212.181 as permitted sender) Received: from [209.85.212.181] (HELO mail-wi0-f181.google.com) (209.85.212.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 15:39:45 +0000 Received: by mail-wi0-f181.google.com with SMTP id ex4so738457wid.2 for ; Fri, 20 Sep 2013 08:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=olpDC8hPaDo3rbfgVL/RM/gNUqVySpXq93xOX5dv05g=; b=OzzuUUFK2DHX6C76IrfX9MMrS9HgOzJT8w4x5vLUdwRgsU0Mh5p43Zsukb2ujO0B9C CEMNs1Oq+nZB7xw1DkvD8tKJyTw8MXDodBCNUNnSr00nWluH+p6xZyU/QuNsnTYqNGj0 k6VgcTT4TVu3wI/dtnMHcPBqIy+KkL/XMeAkO68vsVYAcoAxCs9YMmtkp1KeH33QaZKd vIRtMQrd7SsVP3JfgsGHNS1LAomOw8Ic5/arkLu5bS/8KHKpLXCxQhOx6N1y/x+3Q81r FefzYMXUlKJlAvqE1jErh4AnomrGU/aJfJ/zArWEKESv9XI3FXenkABoKo1gJ3DYM133 Ntmg== X-Received: by 10.180.74.164 with SMTP id u4mr3244824wiv.17.1379691564733; Fri, 20 Sep 2013 08:39:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.238.68 with HTTP; Fri, 20 Sep 2013 08:39:04 -0700 (PDT) In-Reply-To: References: From: Shai Erera Date: Fri, 20 Sep 2013 18:39:04 +0300 Message-ID: Subject: Re: Difference between CustomScoreProvider, FunctionQuery and Expression To: "dev@lucene.apache.org" Content-Type: multipart/alternative; boundary=f46d043c7f569d9ce904e6d279dd X-Virus-Checked: Checked by ClamAV on apache.org --f46d043c7f569d9ce904e6d279dd Content-Type: text/plain; charset=ISO-8859-1 Thanks Rob. So is there a NumericDVFieldSource-like in Lucene? I think it's important that we have one. Shai On Fri, Sep 20, 2013 at 6:10 PM, Robert Muir wrote: > thats what it does. its more like a computed field. and you can sort > by more than one of them. > > please see the JIRA issue for a description of the differences between > function queries. > > On Fri, Sep 20, 2013 at 10:49 AM, Shai Erera wrote: > > Yes, you're right, but that's unrelated to this thread. I passed > > doScore=true and the scores come out the same, meaning Expression didn't > > affect the actual score, only the sort-by value (which is ok). > > > > search Expression > > doc=1, score=0.37158427, field=0.7431685328483582 > > doc=0, score=0.37158427, field=0.3715842664241791 > > > > Shai > > > > > > On Fri, Sep 20, 2013 at 5:10 PM, Robert Muir wrote: > >> > >> On Fri, Sep 20, 2013 at 8:01 AM, Shai Erera wrote: > >> > > >> > Expression > >> > I tried the new module, following TestDemoExpression and compiled the > >> > expression using this code: > >> > > >> > Expression expr = JavascriptCompiler.compile("_score * boost"); > >> > SimpleBindings bindings = new SimpleBindings(); > >> > bindings.add(new SortField("_score", SortField.Type.SCORE)); > >> > bindings.add(new SortField("boost", SortField.Type.LONG)); > >> > > >> > The result scores are: > >> > > >> > search Expression > >> > doc=1, score=NaN, field=0.7431685328483582 > >> > doc=0, score=NaN, field=0.3715842664241791 > >> > > >> > As you can see, both CustomScoreProvider and Expression methods return > >> > same > >> > scores for the docs, while the FunctionQuery method returns different > >> > scores. The reason is that when using FunctionQuery, the scores of the > >> > ValueSources are multiplied by queryWeight, which seems correct to me. > >> > > >> > Expression is more about sorting than scoring as far as I understand > >> > (for > >> > instance, the result FieldDocs.score is NaN) > >> > >> Why does that come as a surprise to you? Pass true to indexsearcher > >> to get the documents score back here. > >> > >> ======================= Release 2.9.0 2009-09-23 ======================= > >> > >> Changes in backwards compatibility policy > >> > >> LUCENE-1575: Searchable.search(Weight, Filter, int, Sort) no longer > >> computes a document score for each hit by default. > >> ... (Shai Erera via Mike McCandless) > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org > >> For additional commands, e-mail: dev-help@lucene.apache.org > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org > For additional commands, e-mail: dev-help@lucene.apache.org > > --f46d043c7f569d9ce904e6d279dd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Rob. So is there a NumericDVFieldSource-like in Luc= ene? I think it's important that we have one.

Shai


On Fri, Sep 20, 2= 013 at 6:10 PM, Robert Muir <rcmuir@gmail.com> wrote:
thats what it does. its more like a computed= field. and you can sort
by more than one of them.

please see the JIRA issue for a description of the differences between
function queries.

On Fri, Sep 20, 2013 at 10:49 A= M, Shai Erera <serera@gmail.com&= gt; wrote:
> Yes, you're right, but that's unrelated to this thread. I pass= ed
> doScore=3Dtrue and the scores come out the same, meaning Expression di= dn't
> affect the actual score, only the sort-by value (which is ok).
>
> search Expression
> doc=3D1, score=3D0.3= 7158427, field=3D0.7431685328483582
> doc=3D0, score=3D0.3= 7158427, field=3D0.3715842664241791
>
> Shai
>
>
> On Fri, Sep 20, 2013 at 5:= 10 PM, Robert Muir <rcmuir@gmail.com= > wrote:
>>
>> On Fri, Sep 20, 2013 a= t 8:01 AM, Shai Erera <serera@gmail.= com> wrote:
>> >
>> > Expression
>> > I tried the new module, following TestDemoExpression and comp= iled the
>> > expression using this code:
>> >
>> > =A0 =A0 Expression expr =3D JavascriptCompiler.compile("= _score * boost");
>> > =A0 =A0 SimpleBindings bindings =3D new SimpleBindings();
>> > =A0 =A0 bindings.add(new SortField("_score", SortFi= eld.Type.SCORE));
>> > =A0 =A0 bindings.add(new SortField("boost", SortFie= ld.Type.LONG));
>> >
>> > The result scores are:
>> >
>> > search Expression
>> > doc=3D1, score=3DNaN, field=3D0.7431685328483582
>> > doc=3D0, score=3DNaN, field=3D0.3715842664241791
>> >
>> > As you can see, both CustomScoreProvider and Expression metho= ds return
>> > same
>> > scores for the docs, while the FunctionQuery method returns d= ifferent
>> > scores. The reason is that when using FunctionQuery, the scor= es of the
>> > ValueSources are multiplied by queryWeight, which seems corre= ct to me.
>> >
>> > Expression is more about sorting than scoring as far as I und= erstand
>> > (for
>> > instance, the result FieldDocs.score is NaN)
>>
>> Why does that come as a surprise to you? =A0Pass true to indexsear= cher
>> to get the documents score back here.
>>
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Release 2.9.0 2009-09-23 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D
>>
>> Changes in backwards compatibility policy
>>
>> LUCENE-1575: Searchable.search(Weight, Filter, int, Sort) no longe= r
>> computes a document score for each hit by default.
>> ... (Shai Erera via Mike McCandless)
>>
>> ------------------------------------------------------------------= ---
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


--f46d043c7f569d9ce904e6d279dd--