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 galo <ga...@last.fm> on 2007/04/04 20:11:13 UTC

problems finding negative values

Hi,

I have an index consisting on the following fields:

<field name="id" type="long" indexed="true" stored="true"/>
<field name="length" type="integer" indexed="true" stored="true"/>
<field name="key" type="integer" indexed="true" stored="true" 
multiValued="true" />

Each doc has a few key values, some of which are negative.

Ok, I know there's a document that has both 826606443 and -1861807411

If I search with

http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=-1861807411&fl=id,length,key

I get no results, but if I do

http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=826606443&fl=id,length,key

I get the document as expected.

Obviously the key field is configured as a search field, indexed, etc. 
but somehow solr doesn't like negatives. I'm assuming this might have 
something to do with analysers but can't tell how to fix it.. any ideas??

Thanks

galo

Re: problems finding negative values

Posted by galo <ga...@last.fm>.
Ah! thanks.

Wrapping the term in quotes solves the issue, but i've tried escaping 
with \- as Yonik suggested and it doesn't. I guess there's no 
performance difference between both so I can live with quotes but 
anyway, for curiosity sake, should \ work?

thanks,
galo

Jeff Rodenburg wrote:
> This one caught us as well.
> 
> Refer to
> http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Charactersfor 
> 
> understanding what characters need to be escaped for your queries.
> 
> 
> 
> On 4/4/07, galo <ga...@last.fm> wrote:
>>
>> Hi,
>>
>> I have an index consisting on the following fields:
>>
>> <field name="id" type="long" indexed="true" stored="true"/>
>> <field name="length" type="integer" indexed="true" stored="true"/>
>> <field name="key" type="integer" indexed="true" stored="true"
>> multiValued="true" />
>>
>> Each doc has a few key values, some of which are negative.
>>
>> Ok, I know there's a document that has both 826606443 and -1861807411
>>
>> If I search with
>>
>>
>> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=-1861807411&fl=id,length,key 
>>
>>
>> I get no results, but if I do
>>
>>
>> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=826606443&fl=id,length,key 
>>
>>
>> I get the document as expected.
>>
>> Obviously the key field is configured as a search field, indexed, etc.
>> but somehow solr doesn't like negatives. I'm assuming this might have
>> something to do with analysers but can't tell how to fix it.. any ideas??
>>
>> Thanks
>>
>> galo
>>
> 


-- 
Galo Navarro, Developer

galo@last.fm
t. +44 (0)20 7780 7080

Last.fm | http://www.last.fm
Karen House 1-11 Baches Street
London N1 6DL

http://www.last.fm/user/galeote

Re: problems finding negative values

Posted by Jeff Rodenburg <je...@gmail.com>.
This one caught us as well.

Refer to
http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Charactersfor
understanding what characters need to be escaped for your queries.



On 4/4/07, galo <ga...@last.fm> wrote:
>
> Hi,
>
> I have an index consisting on the following fields:
>
> <field name="id" type="long" indexed="true" stored="true"/>
> <field name="length" type="integer" indexed="true" stored="true"/>
> <field name="key" type="integer" indexed="true" stored="true"
> multiValued="true" />
>
> Each doc has a few key values, some of which are negative.
>
> Ok, I know there's a document that has both 826606443 and -1861807411
>
> If I search with
>
>
> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=-1861807411&fl=id,length,key
>
> I get no results, but if I do
>
>
> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=826606443&fl=id,length,key
>
> I get the document as expected.
>
> Obviously the key field is configured as a search field, indexed, etc.
> but somehow solr doesn't like negatives. I'm assuming this might have
> something to do with analysers but can't tell how to fix it.. any ideas??
>
> Thanks
>
> galo
>

Re: problems finding negative values

Posted by Yonik Seeley <yo...@apache.org>.
On 4/4/07, galo <ga...@last.fm> wrote:
> Hi,
>
> I have an index consisting on the following fields:
>
> <field name="id" type="long" indexed="true" stored="true"/>
> <field name="length" type="integer" indexed="true" stored="true"/>
> <field name="key" type="integer" indexed="true" stored="true"
> multiValued="true" />
>
> Each doc has a few key values, some of which are negative.
>
> Ok, I know there's a document that has both 826606443 and -1861807411
>
> If I search with
>
> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=-1861807411&fl=id,length,key
>
> I get no results, but if I do
>
> http://localhost:8080/solr/select/?stylesheet=&version=2.1&start=0&rows=50&indent=on&q=826606443&fl=id,length,key
>
> I get the document as expected.
>
> Obviously the key field is configured as a search field, indexed, etc.
> but somehow solr doesn't like negatives. I'm assuming this might have
> something to do with analysers but can't tell how to fix it.. any ideas??

It doesn't have anything to do with analyzers, it has to do with the
Lucene query parser that Solr uses.  A minus sign means "must not
appear", so
q=-1861807411 means "1861807411" must not appear in the default search field.

Try escaping the "-" by enclosing the search term in quotes, or
backslash escaping it.

q="-1861807411"

-Yonik