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 David <da...@mate1inc.com> on 2010/06/04 22:33:54 UTC

Range query on long value

Hi,

I have an issue with range queries on a long value in our dataset (the 
dataset is fairly large, but i believe the problem still exists for 
smaller datasets).  When i query the index with a range, as such: id:[1 
TO 2000], I get values back that are well outside that range.  Its as if 
the range query is ignoring the values and doing something like id:[* TO 
*]. We are running Solr 1.3.  The value is set as the unique key for the 
index.

Our schema is similar to this:

<field name="id" type="long" indexed="true" stored="true" required="true" />
<field name="field_1" type="slong" indexed="true" stored="false" 
required="true" />
<field name="field_2" type="long" indexed="true" stored="false" 
required="false" />
<field name="field_3" type="long" indexed="true" stored="false" 
required="false" />
                         .
                         .
                         .
<field name="field_n" type="long" indexed="true" stored="true" 
required="false" />

<uniqueKey>id</uniqueKey>


Has anyone else had this problem?  If so, how did you correct it?  
Thanks in advance.

Re: Range query on long value

Posted by David <da...@mate1inc.com>.
On 10-06-04 05:11 PM, Ahmet Arslan wrote:
>    
>> I have an issue with range queries on a long value in our
>> dataset (the dataset is fairly large, but i believe the
>> problem still exists for smaller datasets).  When i
>> query the index with a range, as such: id:[1 TO 2000], I get
>> values back that are well outside that range.  Its as
>> if the range query is ignoring the values and doing
>> something like id:[* TO *]. We are running Solr 1.3. 
>> The value is set as the unique key for the index.
>>
>> Our schema is similar to this:
>>
>> <field name="id" type="long" indexed="true"
>> stored="true" required="true" />
>> <field name="field_1" type="slong" indexed="true"
>> stored="false" required="true" />
>> <field name="field_2" type="long" indexed="true"
>> stored="false" required="false" />
>> <field name="field_3" type="long" indexed="true"
>> stored="false" required="false" />
>>      
> You need to use sortable double in solr 1.3.0 type="slong" for range queries to work correctly. Default schema.xml has an explanation about sortable (sint etc) types.
>
>
>
>    
Thanks for the fast response Ahmet.  This fixed my issue, but I have a 
question as to whether there is a performance hit if I change other 
fields to a sortable type, even if im not sure they will ever be used 
for range searches?

Re: Range query on long value

Posted by Ahmet Arslan <io...@yahoo.com>.
> I have an issue with range queries on a long value in our
> dataset (the dataset is fairly large, but i believe the
> problem still exists for smaller datasets).  When i
> query the index with a range, as such: id:[1 TO 2000], I get
> values back that are well outside that range.  Its as
> if the range query is ignoring the values and doing
> something like id:[* TO *]. We are running Solr 1.3. 
> The value is set as the unique key for the index.
> 
> Our schema is similar to this:
> 
> <field name="id" type="long" indexed="true"
> stored="true" required="true" />
> <field name="field_1" type="slong" indexed="true"
> stored="false" required="true" />
> <field name="field_2" type="long" indexed="true"
> stored="false" required="false" />
> <field name="field_3" type="long" indexed="true"
> stored="false" required="false" />

You need to use sortable double in solr 1.3.0 type="slong" for range queries to work correctly. Default schema.xml has an explanation about sortable (sint etc) types.