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 Christopher Gross <co...@gmail.com> on 2011/10/27 20:34:36 UTC

bbox issue

I'm using the geohash field to store points for my data.  When I do a
bounding box like:

localhost:8080/solr/select?q=point:[-45,-80%20TO%20-24,-39]

I get a data point that falls outside the box: (-73.0335833333333 -50.468155555)

The Spatial Search (http://wiki.apache.org/solr/SpatialSearch) page says:
Exact distance calculations can be somewhat expensive and it can often
make sense to use a quick approximation instead. The bbox filter is
guaranteed to encompass all of the points of interest, but it may also
include other points that are slightly outside of the required
distance.

I had sort of assumed that doing a ranged point search would just keep
it to those points, but I'm getting items outside my requested range.

Is there a way that I can only include items within the box via a
configuration change?

Worst case, I'll store a lat/long pair and do the ranged search
myself, but then I'll have to reindex all my data and make some coding
changes in order for it to work.

Any input would be greatly appreciated!  Thanks!

-- Chris

Re: bbox issue

Posted by Erick Erickson <er...@gmail.com>.
One of the values of people reading docs for
the first time is that they uncover less-than-clear
issues. It's even more valuable if they update
the docs, so please feel free to!

Best
Erick

On Fri, Oct 28, 2011 at 9:43 AM, Christopher Gross <co...@gmail.com> wrote:
> Ah!  That all makes sense.  The example on the SpacialSearchDev page
> should have that bit added in!
>
> I'm back in business now, thanks Yonik!
>
> -- Chris
>
>
>
> On Fri, Oct 28, 2011 at 9:40 AM, Yonik Seeley
> <yo...@lucidimagination.com> wrote:
>> Oops, didn't mean for this conversation to leave the mailing lists.
>>
>> OK, so your lat and lon types were being stored as text but not
>> indexed (hence no search matches).
>> A dynamic field of "*" does tend to hide bugs/problems ;-)
>>
>>> So should I have another for _latLon?  Would it look like:
>>> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>
>>
>> Yep.  It shouldn't be stored though (unless you just want to verify
>> for debugging).
>>
>> -Yonik
>> http://www.lucidimagination.com
>>
>>
>>
>> On Fri, Oct 28, 2011 at 9:35 AM, Christopher Gross <co...@gmail.com> wrote:
>>> Hi Yonik.
>>>
>>> I never made a dynamicField definition for _latLon ... I was following
>>> the examples on http://wiki.apache.org/solr/SpatialSearchDev, so I
>>> just added the field type definition, then the field in the list of
>>> fields.  I wasn't aware that I had to do anything else.  The only
>>> dynamic that I have is:
>>> <dynamicField name="*" type="text" indexed="false" stored="true"
>>> multiValued="true"/>
>>>
>>> So should I have another for _latLon?  Would it look like:
>>> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>
>>>
>>> -- Chris
>>>
>>>
>>>
>>> On Fri, Oct 28, 2011 at 9:27 AM, Yonik Seeley
>>> <yo...@lucidimagination.com> wrote:
>>>> On Fri, Oct 28, 2011 at 8:42 AM, Christopher Gross <co...@gmail.com> wrote:
>>>>> Hi Yonik.
>>>>>
>>>>> I'm having more of a problem now...
>>>>> I made the following lines in my schema.xml (in the appropriate places):
>>>>>
>>>>> <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_latLon"/>
>>>>>
>>>>> <field name="point" type="location" indexed="true" stored="true"
>>>>> required="false"/>
>>>>>
>>>>> I have data (did a q=*:*, found one with a point):
>>>>> <str name="point">48.306074,14.286293</str>
>>>>> <arr name="point_0_latLon">
>>>>> <str>48.306074</str>
>>>>> </arr>
>>>>> <arr name="point_1_latLon">
>>>>> <str>14.286293</str>
>>>>> </arr>
>>>>>
>>>>> I've tried to do a bbox:
>>>>> q=*:*&fq=point:[30.0,10.0%20TO%2050.0,20.0]
>>>>> q=*:*&fq={!bbox}&sfield=point&pt=48,14&d=50
>>>>>
>>>>> And neither of those seem to find the point...
>>>>
>>>> Hmmm, what's the dynamicField definition for _latLon?  Is it indexed?
>>>> If you add debugQuery=true, you should be able to see the underlying
>>>> range queries for your explicit range query.
>>>>
>>>> -Yonik
>>>> http://www.lucidimagination.com
>>>>
>>>
>>
>

Re: bbox issue

Posted by Christopher Gross <co...@gmail.com>.
Ah!  That all makes sense.  The example on the SpacialSearchDev page
should have that bit added in!

I'm back in business now, thanks Yonik!

-- Chris



On Fri, Oct 28, 2011 at 9:40 AM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> Oops, didn't mean for this conversation to leave the mailing lists.
>
> OK, so your lat and lon types were being stored as text but not
> indexed (hence no search matches).
> A dynamic field of "*" does tend to hide bugs/problems ;-)
>
>> So should I have another for _latLon?  Would it look like:
>> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>
>
> Yep.  It shouldn't be stored though (unless you just want to verify
> for debugging).
>
> -Yonik
> http://www.lucidimagination.com
>
>
>
> On Fri, Oct 28, 2011 at 9:35 AM, Christopher Gross <co...@gmail.com> wrote:
>> Hi Yonik.
>>
>> I never made a dynamicField definition for _latLon ... I was following
>> the examples on http://wiki.apache.org/solr/SpatialSearchDev, so I
>> just added the field type definition, then the field in the list of
>> fields.  I wasn't aware that I had to do anything else.  The only
>> dynamic that I have is:
>> <dynamicField name="*" type="text" indexed="false" stored="true"
>> multiValued="true"/>
>>
>> So should I have another for _latLon?  Would it look like:
>> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>
>>
>> -- Chris
>>
>>
>>
>> On Fri, Oct 28, 2011 at 9:27 AM, Yonik Seeley
>> <yo...@lucidimagination.com> wrote:
>>> On Fri, Oct 28, 2011 at 8:42 AM, Christopher Gross <co...@gmail.com> wrote:
>>>> Hi Yonik.
>>>>
>>>> I'm having more of a problem now...
>>>> I made the following lines in my schema.xml (in the appropriate places):
>>>>
>>>> <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_latLon"/>
>>>>
>>>> <field name="point" type="location" indexed="true" stored="true"
>>>> required="false"/>
>>>>
>>>> I have data (did a q=*:*, found one with a point):
>>>> <str name="point">48.306074,14.286293</str>
>>>> <arr name="point_0_latLon">
>>>> <str>48.306074</str>
>>>> </arr>
>>>> <arr name="point_1_latLon">
>>>> <str>14.286293</str>
>>>> </arr>
>>>>
>>>> I've tried to do a bbox:
>>>> q=*:*&fq=point:[30.0,10.0%20TO%2050.0,20.0]
>>>> q=*:*&fq={!bbox}&sfield=point&pt=48,14&d=50
>>>>
>>>> And neither of those seem to find the point...
>>>
>>> Hmmm, what's the dynamicField definition for _latLon?  Is it indexed?
>>> If you add debugQuery=true, you should be able to see the underlying
>>> range queries for your explicit range query.
>>>
>>> -Yonik
>>> http://www.lucidimagination.com
>>>
>>
>

Re: bbox issue

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Oops, didn't mean for this conversation to leave the mailing lists.

OK, so your lat and lon types were being stored as text but not
indexed (hence no search matches).
A dynamic field of "*" does tend to hide bugs/problems ;-)

> So should I have another for _latLon?  Would it look like:
> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>

Yep.  It shouldn't be stored though (unless you just want to verify
for debugging).

-Yonik
http://www.lucidimagination.com



On Fri, Oct 28, 2011 at 9:35 AM, Christopher Gross <co...@gmail.com> wrote:
> Hi Yonik.
>
> I never made a dynamicField definition for _latLon ... I was following
> the examples on http://wiki.apache.org/solr/SpatialSearchDev, so I
> just added the field type definition, then the field in the list of
> fields.  I wasn't aware that I had to do anything else.  The only
> dynamic that I have is:
> <dynamicField name="*" type="text" indexed="false" stored="true"
> multiValued="true"/>
>
> So should I have another for _latLon?  Would it look like:
> <dynamicField name="*_latLon" type="double" indexed="true" stored="true"/>
>
> -- Chris
>
>
>
> On Fri, Oct 28, 2011 at 9:27 AM, Yonik Seeley
> <yo...@lucidimagination.com> wrote:
>> On Fri, Oct 28, 2011 at 8:42 AM, Christopher Gross <co...@gmail.com> wrote:
>>> Hi Yonik.
>>>
>>> I'm having more of a problem now...
>>> I made the following lines in my schema.xml (in the appropriate places):
>>>
>>> <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_latLon"/>
>>>
>>> <field name="point" type="location" indexed="true" stored="true"
>>> required="false"/>
>>>
>>> I have data (did a q=*:*, found one with a point):
>>> <str name="point">48.306074,14.286293</str>
>>> <arr name="point_0_latLon">
>>> <str>48.306074</str>
>>> </arr>
>>> <arr name="point_1_latLon">
>>> <str>14.286293</str>
>>> </arr>
>>>
>>> I've tried to do a bbox:
>>> q=*:*&fq=point:[30.0,10.0%20TO%2050.0,20.0]
>>> q=*:*&fq={!bbox}&sfield=point&pt=48,14&d=50
>>>
>>> And neither of those seem to find the point...
>>
>> Hmmm, what's the dynamicField definition for _latLon?  Is it indexed?
>> If you add debugQuery=true, you should be able to see the underlying
>> range queries for your explicit range query.
>>
>> -Yonik
>> http://www.lucidimagination.com
>>
>

Re: bbox issue

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Oct 27, 2011 at 3:22 PM, Christopher Gross <co...@gmail.com> wrote:
> I can roll back and use the LatLon type -- but then I'm still
> concerned about the bounding box giving results outside the specified
> range.

The implementation of things like bbox are intimately tied to the
field type (i.e. normally completely different code).
LatLon bbox should work fine, but please let us know if it doesn't!

-Yonik
http://www.lucidimagination.com

Re: bbox issue

Posted by Christopher Gross <co...@gmail.com>.
True -- I found the geohash on a separate page.  I was using it
because it can allow for multiple points, and I was hoping to be ahead
of the curve for allowing that feature for the data I'm managing.

I can roll back and use the LatLon type -- but then I'm still
concerned about the bounding box giving results outside the specified
range.  Or would I be better off just indexing a lat & lon in separate
fields, then making a normal numeric ranged search against them.

-- Chris



On Thu, Oct 27, 2011 at 3:09 PM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> On Thu, Oct 27, 2011 at 2:34 PM, Christopher Gross <co...@gmail.com> wrote:
>> I'm using the geohash field to store points for my data.  When I do a
>> bounding box like:
>>
>> localhost:8080/solr/select?q=point:[-45,-80%20TO%20-24,-39]
>>
>> I get a data point that falls outside the box: (-73.0335833333333 -50.468155555)
>
> Is there a reason you're using geohash and not LatLonType?
> The SpatialSearch page is really only applicable to LatLonType - other
> methods are currently not supported or well tested (and geohash is not
> mentioned on that page, except in reference to a "things in
> development" page).
>
> -Yonik
> http://www.lucidimagination.com
>
>
>> The Spatial Search (http://wiki.apache.org/solr/SpatialSearch) page says:
>> Exact distance calculations can be somewhat expensive and it can often
>> make sense to use a quick approximation instead. The bbox filter is
>> guaranteed to encompass all of the points of interest, but it may also
>> include other points that are slightly outside of the required
>> distance.
>>
>> I had sort of assumed that doing a ranged point search would just keep
>> it to those points, but I'm getting items outside my requested range.
>>
>> Is there a way that I can only include items within the box via a
>> configuration change?
>>
>> Worst case, I'll store a lat/long pair and do the ranged search
>> myself, but then I'll have to reindex all my data and make some coding
>> changes in order for it to work.
>>
>> Any input would be greatly appreciated!  Thanks!
>>
>> -- Chris
>>
>

Re: bbox issue

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Oct 27, 2011 at 2:34 PM, Christopher Gross <co...@gmail.com> wrote:
> I'm using the geohash field to store points for my data.  When I do a
> bounding box like:
>
> localhost:8080/solr/select?q=point:[-45,-80%20TO%20-24,-39]
>
> I get a data point that falls outside the box: (-73.0335833333333 -50.468155555)

Is there a reason you're using geohash and not LatLonType?
The SpatialSearch page is really only applicable to LatLonType - other
methods are currently not supported or well tested (and geohash is not
mentioned on that page, except in reference to a "things in
development" page).

-Yonik
http://www.lucidimagination.com


> The Spatial Search (http://wiki.apache.org/solr/SpatialSearch) page says:
> Exact distance calculations can be somewhat expensive and it can often
> make sense to use a quick approximation instead. The bbox filter is
> guaranteed to encompass all of the points of interest, but it may also
> include other points that are slightly outside of the required
> distance.
>
> I had sort of assumed that doing a ranged point search would just keep
> it to those points, but I'm getting items outside my requested range.
>
> Is there a way that I can only include items within the box via a
> configuration change?
>
> Worst case, I'll store a lat/long pair and do the ranged search
> myself, but then I'll have to reindex all my data and make some coding
> changes in order for it to work.
>
> Any input would be greatly appreciated!  Thanks!
>
> -- Chris
>