You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Elodie Sannier <el...@kelkoo.fr> on 2013/09/10 15:25:26 UTC

Unexpected value for boolean field in FunctionQuery

Hello,

I am using the solr version 4.4.0, when I'm using FunctionQuery with boolean fields, it seems that the default field value  is "true" for documents without a value in the field.

The page http://wiki.apache.org/solr/FunctionQuery#field says "0 is returned for documents without a value in the field." so we could expect that the field value would be "false".

Starting from the "SolrCloud - Getting Started" page with the document exampledocs/ipod_video.xml and removing the boolean field "inStock": <field name="inStock">true</field> demonstrates the problem.
When requesting with bf=if(inStock,10,0) :
curl -sS "http://localhost:8983/solr/select?q=*:*&bf=if%28inStock,10,0%29&defType=edismax&debugQuery=true"
Result indicates that field value for boolean field "inStock" is seen as "true" :
7.071068 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))), product of:
     10.0 = if(bool(inStock)=true,const(10),const(0))
     1.0 = boost
     0.70710677 = queryNorm

Same behaviour using FunctionQuery via LocalParams syntax :
http://localhost:8983/solr/select?q={!func}if%28inStock,10,0%29&debugQuery=true
10.0 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))), product of:
   10.0 = if(bool(inStock)=true,const(10),const(0))
   1.0 = boost
   1.0 = queryNorm

Is that expected ?

Elodie Sannier


Kelkoo SAS
Société par Actions Simplifiée
Au capital de € 4.168.964,30
Siège social : 8, rue du Sentier 75002 Paris
425 093 069 RCS Paris

Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.

Re: Unexpected value for boolean field in FunctionQuery

Posted by Chris Hostetter <ho...@fucit.org>.
: When I use your url example
: http://localhost:8983/solr/select?q=*:*&rows=100&fl=id,inStock,if%28inStock,10,0%29&debugQuery=true
: I have :
: <long name="if(inStock,10,0)">10</long>
: (and my document does not have the inStock field)

Elodie, this is definitely a tricy one...

I can reproduce the problme you are describing, on 4.3, 4.4, and trunk -- 
but aparently it only happens when there are no other docs in the segment 
that have a value for that field???

i've filled a bug for this...

https://issues.apache.org/jira/browse/SOLR-5231

...but i have no idea what's going on.

the work arround seems to be to use the exists() function explicitly in 
your if() condition.


-Hoss

Re: Unexpected value for boolean field in FunctionQuery

Posted by Elodie Sannier <el...@kelkoo.fr>.
By the way Yonik which version do you use (4.4.0 or nightly) ?

Elodie

On 09/10/2013 04:06 PM, Elodie Sannier wrote:
> I didn't forget to commit my changes.
> I used commands:
> java -Durl=http://localhost:8983/solr/collection1/update -jar post.jar
> ipod_video.xml
> curl 'http://localhost:8983/solr/collection1/update/?commit=true'
>
> When I use your url example
> http://localhost:8983/solr/select?q=*:*&rows=100&fl=id,inStock,if%28inStock,10,0%29&debugQuery=true
> I have :
> <long name="if(inStock,10,0)">10</long>
> (and my document does not have the inStock field)
>
> Elodie
>
> On 09/10/2013 03:54 PM, Yonik Seeley wrote:
>> I just tried a simple test with the example data, and things seem to
>> be working fine...
>>
>> I tried this:
>> http://localhost:8983/solr/select
>>     ?q=*:*
>>     &rows=100
>>     &fl=id, inStock, if(inStock,10,0)
>>
>> I saw values of 10 when inStock==true and values of 0 when it was
>> missing or explicitly false.
>> Perhaps you forgot to commit your changes when you removed the inStock
>> field from one of the example docs?
>>
>> -Yonik
>> http://lucidworks.com
>>
>>
>> On Tue, Sep 10, 2013 at 9:25 AM, Elodie Sannier
>> <el...@kelkoo.fr> wrote:
>>> Hello,
>>>
>>> I am using the solr version 4.4.0, when I'm using FunctionQuery with boolean
>>> fields, it seems that the default field value  is "true" for documents
>>> without a value in the field.
>>>
>>> The page http://wiki.apache.org/solr/FunctionQuery#field says "0 is returned
>>> for documents without a value in the field." so we could expect that the
>>> field value would be "false".
>>>
>>> Starting from the "SolrCloud - Getting Started" page with the document
>>> exampledocs/ipod_video.xml and removing the boolean field "inStock": <field
>>> name="inStock">true</field> demonstrates the problem.
>>> When requesting with bf=if(inStock,10,0) :
>>> curl -sS
>>> "http://localhost:8983/solr/select?q=*:*&bf=if%28inStock,10,0%29&defType=edismax&debugQuery=true"
>>> Result indicates that field value for boolean field "inStock" is seen as
>>> "true" :
>>> 7.071068 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))),
>>> product of:
>>>       10.0 = if(bool(inStock)=true,const(10),const(0))
>>>       1.0 = boost
>>>       0.70710677 = queryNorm
>>>
>>> Same behaviour using FunctionQuery via LocalParams syntax :
>>> http://localhost:8983/solr/select?q={!func}if%28inStock,10,0%29&debugQuery=true
>>> 10.0 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))), product
>>> of:
>>>     10.0 = if(bool(inStock)=true,const(10),const(0))
>>>     1.0 = boost
>>>     1.0 = queryNorm
>>>
>>> Is that expected ?
>>>
>>> Elodie Sannier
>>>
>>>
>>> Kelkoo SAS
>>> Société par Actions Simplifiée
>>> Au capital de € 4.168.964,30
>>> Siège social : 8, rue du Sentier 75002 Paris
>>> 425 093 069 RCS Paris
>>>
>>> Ce message et les pièces jointes sont confidentiels et établis à l'attention
>>> exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce
>>> message, merci de le détruire et d'en avertir l'expéditeur.
>
> Kelkoo SAS
> Société par Actions Simplifiée
> Au capital de € 4.168.964,30
> Siège social : 8, rue du Sentier 75002 Paris
> 425 093 069 RCS Paris
>
> Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.
>
>


Kelkoo SAS
Société par Actions Simplifiée
Au capital de € 4.168.964,30
Siège social : 8, rue du Sentier 75002 Paris
425 093 069 RCS Paris

Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.

Re: Unexpected value for boolean field in FunctionQuery

Posted by Elodie Sannier <el...@kelkoo.fr>.
I didn't forget to commit my changes.
I used commands:
java -Durl=http://localhost:8983/solr/collection1/update -jar post.jar
ipod_video.xml
curl 'http://localhost:8983/solr/collection1/update/?commit=true'

When I use your url example
http://localhost:8983/solr/select?q=*:*&rows=100&fl=id,inStock,if%28inStock,10,0%29&debugQuery=true
I have :
<long name="if(inStock,10,0)">10</long>
(and my document does not have the inStock field)

Elodie

On 09/10/2013 03:54 PM, Yonik Seeley wrote:
> I just tried a simple test with the example data, and things seem to
> be working fine...
>
> I tried this:
> http://localhost:8983/solr/select
>    ?q=*:*
>    &rows=100
>    &fl=id, inStock, if(inStock,10,0)
>
> I saw values of 10 when inStock==true and values of 0 when it was
> missing or explicitly false.
> Perhaps you forgot to commit your changes when you removed the inStock
> field from one of the example docs?
>
> -Yonik
> http://lucidworks.com
>
>
> On Tue, Sep 10, 2013 at 9:25 AM, Elodie Sannier
> <el...@kelkoo.fr> wrote:
>> Hello,
>>
>> I am using the solr version 4.4.0, when I'm using FunctionQuery with boolean
>> fields, it seems that the default field value  is "true" for documents
>> without a value in the field.
>>
>> The page http://wiki.apache.org/solr/FunctionQuery#field says "0 is returned
>> for documents without a value in the field." so we could expect that the
>> field value would be "false".
>>
>> Starting from the "SolrCloud - Getting Started" page with the document
>> exampledocs/ipod_video.xml and removing the boolean field "inStock": <field
>> name="inStock">true</field> demonstrates the problem.
>> When requesting with bf=if(inStock,10,0) :
>> curl -sS
>> "http://localhost:8983/solr/select?q=*:*&bf=if%28inStock,10,0%29&defType=edismax&debugQuery=true"
>> Result indicates that field value for boolean field "inStock" is seen as
>> "true" :
>> 7.071068 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))),
>> product of:
>>      10.0 = if(bool(inStock)=true,const(10),const(0))
>>      1.0 = boost
>>      0.70710677 = queryNorm
>>
>> Same behaviour using FunctionQuery via LocalParams syntax :
>> http://localhost:8983/solr/select?q={!func}if%28inStock,10,0%29&debugQuery=true
>> 10.0 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))), product
>> of:
>>    10.0 = if(bool(inStock)=true,const(10),const(0))
>>    1.0 = boost
>>    1.0 = queryNorm
>>
>> Is that expected ?
>>
>> Elodie Sannier
>>
>>
>> Kelkoo SAS
>> Société par Actions Simplifiée
>> Au capital de € 4.168.964,30
>> Siège social : 8, rue du Sentier 75002 Paris
>> 425 093 069 RCS Paris
>>
>> Ce message et les pièces jointes sont confidentiels et établis à l'attention
>> exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce
>> message, merci de le détruire et d'en avertir l'expéditeur.
>


Kelkoo SAS
Société par Actions Simplifiée
Au capital de € 4.168.964,30
Siège social : 8, rue du Sentier 75002 Paris
425 093 069 RCS Paris

Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.

Re: Unexpected value for boolean field in FunctionQuery

Posted by Yonik Seeley <yo...@lucidworks.com>.
I just tried a simple test with the example data, and things seem to
be working fine...

I tried this:
http://localhost:8983/solr/select
  ?q=*:*
  &rows=100
  &fl=id, inStock, if(inStock,10,0)

I saw values of 10 when inStock==true and values of 0 when it was
missing or explicitly false.
Perhaps you forgot to commit your changes when you removed the inStock
field from one of the example docs?

-Yonik
http://lucidworks.com


On Tue, Sep 10, 2013 at 9:25 AM, Elodie Sannier
<el...@kelkoo.fr> wrote:
> Hello,
>
> I am using the solr version 4.4.0, when I'm using FunctionQuery with boolean
> fields, it seems that the default field value  is "true" for documents
> without a value in the field.
>
> The page http://wiki.apache.org/solr/FunctionQuery#field says "0 is returned
> for documents without a value in the field." so we could expect that the
> field value would be "false".
>
> Starting from the "SolrCloud - Getting Started" page with the document
> exampledocs/ipod_video.xml and removing the boolean field "inStock": <field
> name="inStock">true</field> demonstrates the problem.
> When requesting with bf=if(inStock,10,0) :
> curl -sS
> "http://localhost:8983/solr/select?q=*:*&bf=if%28inStock,10,0%29&defType=edismax&debugQuery=true"
> Result indicates that field value for boolean field "inStock" is seen as
> "true" :
> 7.071068 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))),
> product of:
>     10.0 = if(bool(inStock)=true,const(10),const(0))
>     1.0 = boost
>     0.70710677 = queryNorm
>
> Same behaviour using FunctionQuery via LocalParams syntax :
> http://localhost:8983/solr/select?q={!func}if%28inStock,10,0%29&debugQuery=true
> 10.0 = (MATCH) FunctionQuery(if(bool(inStock),const(10),const(0))), product
> of:
>   10.0 = if(bool(inStock)=true,const(10),const(0))
>   1.0 = boost
>   1.0 = queryNorm
>
> Is that expected ?
>
> Elodie Sannier
>
>
> Kelkoo SAS
> Société par Actions Simplifiée
> Au capital de € 4.168.964,30
> Siège social : 8, rue du Sentier 75002 Paris
> 425 093 069 RCS Paris
>
> Ce message et les pièces jointes sont confidentiels et établis à l'attention
> exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce
> message, merci de le détruire et d'en avertir l'expéditeur.