Range search problem on float values

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Range search problem on float values

Peter McPeterson
Hi all, I'm having a problem doing a range search on float values. The field
types for longitude and latitude were text, then I changed to float to give
it a try but I'm still having problems.

The correct search string would be:
latitude:[32.71852 TO 32.792765] AND longitude:[-117.159316 TO -116.966504]
which doesn't work

but if I invert the longitude:
latitude:[32.71852 TO 32.792765] AND longitude:[-116.966504 TO -117.159316]
it works fine, but isn't the correct way of doing it

Any thoughts?

Thanks.

_________________________________________________________________
The average US Credit Score is 675. The cost to see yours: $0 by Experian.
http://www.freecreditreport.com/pm/default.aspx?sc=660600&bcd=EMAILFOOTERAVERAGE

Reply | Threaded
Open this post in threaded view
|

Re: Range search problem on float values

Yonik Seeley-2
On 2/15/07, Peter McPeterson <[hidden email]> wrote:
> Hi all, I'm having a problem doing a range search on float values. The field
> types for longitude and latitude were text, then I changed to float to give
> it a try but I'm still having problems.
>
> The correct search string would be:
> latitude:[32.71852 TO 32.792765] AND longitude:[-117.159316 TO -116.966504]
> which doesn't work

Did you re-index after you changed the field type?
If you compare the field values as text, -116 comes before -117

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Range search problem on float values

Chris Hostetter-3
In reply to this post by Peter McPeterson
: Hi all, I'm having a problem doing a range search on float values. The field
: types for longitude and latitude were text, then I changed to float to give
: it a try but I'm still having problems.

are you using "float" or "sfloat" ... float stores floats, but doesn't so
the super special magic sauce that makes them sort properly (which is
neccessary for doing range queries)



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Range search problem on float values

Peter McPeterson
Yonik, yes, I did re-index the data after changing the field type. And
Chris, yes, I am using float.

Any other thoughts on what could be causing it to behave this way? So weird
behaviour.

Thanks.


>From: Chris Hostetter <[hidden email]>
>Reply-To: [hidden email]
>To: [hidden email]
>Subject: Re: Range search problem on float values
>Date: Thu, 15 Feb 2007 21:02:05 -0800 (PST)
>
>: Hi all, I'm having a problem doing a range search on float values. The
>field
>: types for longitude and latitude were text, then I changed to float to
>give
>: it a try but I'm still having problems.
>
>are you using "float" or "sfloat" ... float stores floats, but doesn't so
>the super special magic sauce that makes them sort properly (which is
>neccessary for doing range queries)
>
>
>
>-Hoss
>

_________________________________________________________________
Play Flexicon: the crossword game that feeds your brain. PLAY now for FREE. 
  http://zone.msn.com/en/flexicon/default.htm?icid=flexicon_hmtagline

Reply | Threaded
Open this post in threaded view
|

Re: Range search problem on float values

Yonik Seeley-2
On 2/16/07, Peter McPeterson <[hidden email]> wrote:
> Yonik, yes, I did re-index the data after changing the field type. And
> Chris, yes, I am using float.

Ah ha... the comments in the example schema say it all.  You need
sfloat if you need range queries.  Slightly confusing to have these
different numeric types, I know... it's because lucene sort of had a
type of float for sorting purposes.

    <!-- numeric field types that store and index the text
         value verbatim (and hence don't support range queries, since the
         lexicographic ordering isn't equal to the numeric ordering) -->
    <fieldtype name="integer" class="solr.IntField" omitNorms="true"/>
    <fieldtype name="long" class="solr.LongField" omitNorms="true"/>
    <fieldtype name="float" class="solr.FloatField" omitNorms="true"/>
    <fieldtype name="double" class="solr.DoubleField" omitNorms="true"/>


    <!-- Numeric field types that manipulate the value into
         a string value that isn't human-readable in its internal form,
         but with a lexicographic ordering the same as the numeric ordering,
         so that range queries work correctly. -->
    <fieldtype name="sint" class="solr.SortableIntField" sortMissingLast="true"
omitNorms="true"/>
    <fieldtype name="slong" class="solr.SortableLongField" sortMissingLast="true
" omitNorms="true"/>
    <fieldtype name="sfloat" class="solr.SortableFloatField" sortMissingLast="tr
ue" omitNorms="true"/>
    <fieldtype name="sdouble" class="solr.SortableDoubleField" sortMissingLast="
true" omitNorms="true"/>

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Range search problem on float values

Peter McPeterson
Ah ha! Awesome thanks.


>From: "Yonik Seeley" <[hidden email]>
>Reply-To: [hidden email]
>To: [hidden email]
>Subject: Re: Range search problem on float values
>Date: Fri, 16 Feb 2007 01:01:33 -0500
>
>On 2/16/07, Peter McPeterson <[hidden email]> wrote:
>>Yonik, yes, I did re-index the data after changing the field type. And
>>Chris, yes, I am using float.
>
>Ah ha... the comments in the example schema say it all.  You need
>sfloat if you need range queries.  Slightly confusing to have these
>different numeric types, I know... it's because lucene sort of had a
>type of float for sorting purposes.
>
>    <!-- numeric field types that store and index the text
>         value verbatim (and hence don't support range queries, since the
>         lexicographic ordering isn't equal to the numeric ordering) -->
>    <fieldtype name="integer" class="solr.IntField" omitNorms="true"/>
>    <fieldtype name="long" class="solr.LongField" omitNorms="true"/>
>    <fieldtype name="float" class="solr.FloatField" omitNorms="true"/>
>    <fieldtype name="double" class="solr.DoubleField" omitNorms="true"/>
>
>
>    <!-- Numeric field types that manipulate the value into
>         a string value that isn't human-readable in its internal form,
>         but with a lexicographic ordering the same as the numeric
>ordering,
>         so that range queries work correctly. -->
>    <fieldtype name="sint" class="solr.SortableIntField"
>sortMissingLast="true"
>omitNorms="true"/>
>    <fieldtype name="slong" class="solr.SortableLongField"
>sortMissingLast="true
>" omitNorms="true"/>
>    <fieldtype name="sfloat" class="solr.SortableFloatField"
>sortMissingLast="tr
>ue" omitNorms="true"/>
>    <fieldtype name="sdouble" class="solr.SortableDoubleField"
>sortMissingLast="
>true" omitNorms="true"/>
>
>-Yonik

_________________________________________________________________
Mortgage rates as low as 4.625% - Refinance $150,000 loan for $579 a month.
Intro*Terms  
https://www2.nextag.com/goto.jsp?product=100000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h27f6&disc=y&vers=743&s=4056&p=5117