geodist and spacial search

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

geodist and spacial search

Eric Grobler
Hi

In http://wiki.apache.org/solr/SpatialSearch
there is an example of a bbox filter and a geodist function.

Is it possible to do a bbox filter and sort by distance - combine the two?

Thanks
Ericz
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Erick Erickson
Further down that very page <G>...

Here's an example of sorting by distance ascending:

   -

   ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
asc<http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc>




The key is just the &sort=geodist(), I'm pretty sure that's independent of
the bbox, but
I could be wrong.

Best
Erick

On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <[hidden email]>wrote:

> Hi
>
> In http://wiki.apache.org/solr/SpatialSearch
> there is an example of a bbox filter and a geodist function.
>
> Is it possible to do a bbox filter and sort by distance - combine the two?
>
> Thanks
> Ericz
>
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Eric Grobler
Hi Erick,

Thanks I saw that example, but I am trying to sort by distance AND specify
the max distance in 1 query.

The reason is:
running bbox on 2 million documents with a 20km distance takes only 200ms.
Sorting 2 million documents by distance takes over 1.5 seconds!

So it will be much faster for solr to first filter the 20km documents and
then to sort them.

Regards
Ericz

On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson <[hidden email]>wrote:

> Further down that very page <G>...
>
> Here's an example of sorting by distance ascending:
>
>   -
>
>   ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
> asc<
> http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
> >
>
>
>
>
> The key is just the &sort=geodist(), I'm pretty sure that's independent of
> the bbox, but
> I could be wrong.
>
> Best
> Erick
>
> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <[hidden email]
> >wrote:
>
> > Hi
> >
> > In http://wiki.apache.org/solr/SpatialSearch
> > there is an example of a bbox filter and a geodist function.
> >
> > Is it possible to do a bbox filter and sort by distance - combine the
> two?
> >
> > Thanks
> > Ericz
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Grant Ingersoll-2
Use a filter query?  See the {!geofilt} stuff on the wiki page.  That gives you your filter to restrict down your result set, then you can sort by exact distance to get your sort of just those docs that make it through the filter.


On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:

> Hi Erick,
>
> Thanks I saw that example, but I am trying to sort by distance AND specify
> the max distance in 1 query.
>
> The reason is:
> running bbox on 2 million documents with a 20km distance takes only 200ms.
> Sorting 2 million documents by distance takes over 1.5 seconds!
>
> So it will be much faster for solr to first filter the 20km documents and
> then to sort them.
>
> Regards
> Ericz
>
> On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson <[hidden email]>wrote:
>
>> Further down that very page <G>...
>>
>> Here's an example of sorting by distance ascending:
>>
>>  -
>>
>>  ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
>> asc<
>> http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
>>>
>>
>>
>>
>>
>> The key is just the &sort=geodist(), I'm pretty sure that's independent of
>> the bbox, but
>> I could be wrong.
>>
>> Best
>> Erick
>>
>> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <[hidden email]
>>> wrote:
>>
>>> Hi
>>>
>>> In http://wiki.apache.org/solr/SpatialSearch
>>> there is an example of a bbox filter and a geodist function.
>>>
>>> Is it possible to do a bbox filter and sort by distance - combine the
>> two?
>>>
>>> Thanks
>>> Ericz
>>>
>>

--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem docs using Solr/Lucene:
http://www.lucidimagination.com/search

Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Eric Grobler
Hi Grant,

Thanks for the tip
This seems to work:

q=*:*
fq={!func}geodist()
sfield=store
pt=49.45031,11.077721

fq={!bbox}
sfield=store
pt=49.45031,11.077721
d=40

fl=store
sort=geodist() asc


On Thu, Feb 3, 2011 at 7:46 PM, Grant Ingersoll <[hidden email]> wrote:

> Use a filter query?  See the {!geofilt} stuff on the wiki page.  That gives
> you your filter to restrict down your result set, then you can sort by exact
> distance to get your sort of just those docs that make it through the
> filter.
>
>
> On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:
>
> > Hi Erick,
> >
> > Thanks I saw that example, but I am trying to sort by distance AND
> specify
> > the max distance in 1 query.
> >
> > The reason is:
> > running bbox on 2 million documents with a 20km distance takes only
> 200ms.
> > Sorting 2 million documents by distance takes over 1.5 seconds!
> >
> > So it will be much faster for solr to first filter the 20km documents and
> > then to sort them.
> >
> > Regards
> > Ericz
> >
> > On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson <[hidden email]
> >wrote:
> >
> >> Further down that very page <G>...
> >>
> >> Here's an example of sorting by distance ascending:
> >>
> >>  -
> >>
> >>  ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
> >> asc<
> >>
> http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
> >>>
> >>
> >>
> >>
> >>
> >> The key is just the &sort=geodist(), I'm pretty sure that's independent
> of
> >> the bbox, but
> >> I could be wrong.
> >>
> >> Best
> >> Erick
> >>
> >> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <
> [hidden email]
> >>> wrote:
> >>
> >>> Hi
> >>>
> >>> In http://wiki.apache.org/solr/SpatialSearch
> >>> there is an example of a bbox filter and a geodist function.
> >>>
> >>> Is it possible to do a bbox filter and sort by distance - combine the
> >> two?
> >>>
> >>> Thanks
> >>> Ericz
> >>>
> >>
>
> --------------------------
> Grant Ingersoll
> http://www.lucidimagination.com/
>
> Search the Lucene ecosystem docs using Solr/Lucene:
> http://www.lucidimagination.com/search
>
>
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Billnbell
Why not just:

q=*:*
fq={!bbox}
sfield=store
pt=49.45031,11.077721
d=40
fl=store
sort=geodist() asc


http://localhost:8983/solr/select?q=*:*&sfield=store&pt=49.45031,11.077721&
d=40&fq={!bbox}&sort=geodist%28%29%20asc

That will sort, and filter up to 40km.

No need for the

fq={!func}geodist()
sfield=store
pt=49.45031,11.077721


Bill




On 2/4/11 4:30 AM, "Eric Grobler" <[hidden email]> wrote:

>Hi Grant,
>
>Thanks for the tip
>This seems to work:
>
>q=*:*
>fq={!func}geodist()
>sfield=store
>pt=49.45031,11.077721
>
>fq={!bbox}
>sfield=store
>pt=49.45031,11.077721
>d=40
>
>fl=store
>sort=geodist() asc
>
>
>On Thu, Feb 3, 2011 at 7:46 PM, Grant Ingersoll <[hidden email]>
>wrote:
>
>> Use a filter query?  See the {!geofilt} stuff on the wiki page.  That
>>gives
>> you your filter to restrict down your result set, then you can sort by
>>exact
>> distance to get your sort of just those docs that make it through the
>> filter.
>>
>>
>> On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:
>>
>> > Hi Erick,
>> >
>> > Thanks I saw that example, but I am trying to sort by distance AND
>> specify
>> > the max distance in 1 query.
>> >
>> > The reason is:
>> > running bbox on 2 million documents with a 20km distance takes only
>> 200ms.
>> > Sorting 2 million documents by distance takes over 1.5 seconds!
>> >
>> > So it will be much faster for solr to first filter the 20km documents
>>and
>> > then to sort them.
>> >
>> > Regards
>> > Ericz
>> >
>> > On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson
>><[hidden email]
>> >wrote:
>> >
>> >> Further down that very page <G>...
>> >>
>> >> Here's an example of sorting by distance ascending:
>> >>
>> >>  -
>> >>
>> >>  ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
>> >> asc<
>> >>
>>
>>http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*
>>&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
>> >>>
>> >>
>> >>
>> >>
>> >>
>> >> The key is just the &sort=geodist(), I'm pretty sure that's
>>independent
>> of
>> >> the bbox, but
>> >> I could be wrong.
>> >>
>> >> Best
>> >> Erick
>> >>
>> >> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <
>> [hidden email]
>> >>> wrote:
>> >>
>> >>> Hi
>> >>>
>> >>> In http://wiki.apache.org/solr/SpatialSearch
>> >>> there is an example of a bbox filter and a geodist function.
>> >>>
>> >>> Is it possible to do a bbox filter and sort by distance - combine
>>the
>> >> two?
>> >>>
>> >>> Thanks
>> >>> Ericz
>> >>>
>> >>
>>
>> --------------------------
>> Grant Ingersoll
>> http://www.lucidimagination.com/
>>
>> Search the Lucene ecosystem docs using Solr/Lucene:
>> http://www.lucidimagination.com/search
>>
>>


Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Adam Estrada-2
Use the {!geofilt} param like Grant suggested. IMO, it works the best especially on larger datasets.

Adam

Sent from my iPhone

On Feb 4, 2011, at 10:56 PM, Bill Bell <[hidden email]> wrote:

> Why not just:
>
> q=*:*
> fq={!bbox}
> sfield=store
> pt=49.45031,11.077721
> d=40
> fl=store
> sort=geodist() asc
>
>
> http://localhost:8983/solr/select?q=*:*&sfield=store&pt=49.45031,11.077721&
> d=40&fq={!bbox}&sort=geodist%28%29%20asc
>
> That will sort, and filter up to 40km.
>
> No need for the
>
> fq={!func}geodist()
> sfield=store
> pt=49.45031,11.077721
>
>
> Bill
>
>
>
>
> On 2/4/11 4:30 AM, "Eric Grobler" <[hidden email]> wrote:
>
>> Hi Grant,
>>
>> Thanks for the tip
>> This seems to work:
>>
>> q=*:*
>> fq={!func}geodist()
>> sfield=store
>> pt=49.45031,11.077721
>>
>> fq={!bbox}
>> sfield=store
>> pt=49.45031,11.077721
>> d=40
>>
>> fl=store
>> sort=geodist() asc
>>
>>
>> On Thu, Feb 3, 2011 at 7:46 PM, Grant Ingersoll <[hidden email]>
>> wrote:
>>
>>> Use a filter query?  See the {!geofilt} stuff on the wiki page.  That
>>> gives
>>> you your filter to restrict down your result set, then you can sort by
>>> exact
>>> distance to get your sort of just those docs that make it through the
>>> filter.
>>>
>>>
>>> On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:
>>>
>>>> Hi Erick,
>>>>
>>>> Thanks I saw that example, but I am trying to sort by distance AND
>>> specify
>>>> the max distance in 1 query.
>>>>
>>>> The reason is:
>>>> running bbox on 2 million documents with a 20km distance takes only
>>> 200ms.
>>>> Sorting 2 million documents by distance takes over 1.5 seconds!
>>>>
>>>> So it will be much faster for solr to first filter the 20km documents
>>> and
>>>> then to sort them.
>>>>
>>>> Regards
>>>> Ericz
>>>>
>>>> On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson
>>> <[hidden email]
>>>> wrote:
>>>>
>>>>> Further down that very page <G>...
>>>>>
>>>>> Here's an example of sorting by distance ascending:
>>>>>
>>>>> -
>>>>>
>>>>> ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
>>>>> asc<
>>>>>
>>>
>>> http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*
>>> &sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> The key is just the &sort=geodist(), I'm pretty sure that's
>>> independent
>>> of
>>>>> the bbox, but
>>>>> I could be wrong.
>>>>>
>>>>> Best
>>>>> Erick
>>>>>
>>>>> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <
>>> [hidden email]
>>>>>> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> In http://wiki.apache.org/solr/SpatialSearch
>>>>>> there is an example of a bbox filter and a geodist function.
>>>>>>
>>>>>> Is it possible to do a bbox filter and sort by distance - combine
>>> the
>>>>> two?
>>>>>>
>>>>>> Thanks
>>>>>> Ericz
>>>>>>
>>>>>
>>>
>>> --------------------------
>>> Grant Ingersoll
>>> http://www.lucidimagination.com/
>>>
>>> Search the Lucene ecosystem docs using Solr/Lucene:
>>> http://www.lucidimagination.com/search
>>>
>>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Billnbell
Sure. I just didn't understand why you would use

fq={!func}geodist()
sfield=store
pt=49.45031,11.077721



You would normally use {!geofilt}



On 2/5/11 8:59 AM, "Estrada Groups" <[hidden email]> wrote:

>Use the {!geofilt} param like Grant suggested. IMO, it works the best
>especially on larger datasets.
>
>Adam
>
>Sent from my iPhone
>
>On Feb 4, 2011, at 10:56 PM, Bill Bell <[hidden email]> wrote:
>
>> Why not just:
>>
>> q=*:*
>> fq={!bbox}
>> sfield=store
>> pt=49.45031,11.077721
>> d=40
>> fl=store
>> sort=geodist() asc
>>
>>
>>
>>http://localhost:8983/solr/select?q=*:*&sfield=store&pt=49.45031,11.07772
>>1&
>> d=40&fq={!bbox}&sort=geodist%28%29%20asc
>>
>> That will sort, and filter up to 40km.
>>
>> No need for the
>>
>> fq={!func}geodist()
>> sfield=store
>> pt=49.45031,11.077721
>>
>>
>> Bill
>>
>>
>>
>>
>> On 2/4/11 4:30 AM, "Eric Grobler" <[hidden email]> wrote:
>>
>>> Hi Grant,
>>>
>>> Thanks for the tip
>>> This seems to work:
>>>
>>> q=*:*
>>> fq={!func}geodist()
>>> sfield=store
>>> pt=49.45031,11.077721
>>>
>>> fq={!bbox}
>>> sfield=store
>>> pt=49.45031,11.077721
>>> d=40
>>>
>>> fl=store
>>> sort=geodist() asc
>>>
>>>
>>> On Thu, Feb 3, 2011 at 7:46 PM, Grant Ingersoll <[hidden email]>
>>> wrote:
>>>
>>>> Use a filter query?  See the {!geofilt} stuff on the wiki page.  That
>>>> gives
>>>> you your filter to restrict down your result set, then you can sort by
>>>> exact
>>>> distance to get your sort of just those docs that make it through the
>>>> filter.
>>>>
>>>>
>>>> On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:
>>>>
>>>>> Hi Erick,
>>>>>
>>>>> Thanks I saw that example, but I am trying to sort by distance AND
>>>> specify
>>>>> the max distance in 1 query.
>>>>>
>>>>> The reason is:
>>>>> running bbox on 2 million documents with a 20km distance takes only
>>>> 200ms.
>>>>> Sorting 2 million documents by distance takes over 1.5 seconds!
>>>>>
>>>>> So it will be much faster for solr to first filter the 20km documents
>>>> and
>>>>> then to sort them.
>>>>>
>>>>> Regards
>>>>> Ericz
>>>>>
>>>>> On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson
>>>> <[hidden email]
>>>>> wrote:
>>>>>
>>>>>> Further down that very page <G>...
>>>>>>
>>>>>> Here's an example of sorting by distance ascending:
>>>>>>
>>>>>> -
>>>>>>
>>>>>> ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
>>>>>> asc<
>>>>>>
>>>>
>>>>
>>>>http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*
>>>>:*
>>>> &sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> The key is just the &sort=geodist(), I'm pretty sure that's
>>>> independent
>>>> of
>>>>>> the bbox, but
>>>>>> I could be wrong.
>>>>>>
>>>>>> Best
>>>>>> Erick
>>>>>>
>>>>>> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <
>>>> [hidden email]
>>>>>>> wrote:
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> In http://wiki.apache.org/solr/SpatialSearch
>>>>>>> there is an example of a bbox filter and a geodist function.
>>>>>>>
>>>>>>> Is it possible to do a bbox filter and sort by distance - combine
>>>> the
>>>>>> two?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Ericz
>>>>>>>
>>>>>>
>>>>
>>>> --------------------------
>>>> Grant Ingersoll
>>>> http://www.lucidimagination.com/
>>>>
>>>> Search the Lucene ecosystem docs using Solr/Lucene:
>>>> http://www.lucidimagination.com/search
>>>>
>>>>
>>
>>


Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Yonik Seeley-2-2
In reply to this post by Adam Estrada-2
On Sat, Feb 5, 2011 at 10:59 AM, Estrada Groups
<[hidden email]> wrote:
> Use the {!geofilt} param like Grant suggested. IMO, it works the best especially on larger datasets.

Right, use geofilt if you need to restrict to a radius, or bbox if a
bounding box is sufficient (which is often the case if you are going
to sort by distance anyway).

-Yonik
http://lucidimagination.com
Reply | Threaded
Open this post in threaded view
|

Re: geodist and spacial search

Eric Grobler
In reply to this post by Billnbell
Thanks Bill,

much simpler :-)



On Sat, Feb 5, 2011 at 3:56 AM, Bill Bell <[hidden email]> wrote:

> Why not just:
>
> q=*:*
> fq={!bbox}
> sfield=store
> pt=49.45031,11.077721
> d=40
> fl=store
> sort=geodist() asc
>
>
> http://localhost:8983/solr/select?q=*:*&sfield=store&pt=49.45031,11.077721&
> d=40&fq={!bbox}&sort=geodist%28%29%20asc
>
> That will sort, and filter up to 40km.
>
> No need for the
>
> fq={!func}geodist()
> sfield=store
> pt=49.45031,11.077721
>
>
> Bill
>
>
>
>
> On 2/4/11 4:30 AM, "Eric Grobler" <[hidden email]> wrote:
>
> >Hi Grant,
> >
> >Thanks for the tip
> >This seems to work:
> >
> >q=*:*
> >fq={!func}geodist()
> >sfield=store
> >pt=49.45031,11.077721
> >
> >fq={!bbox}
> >sfield=store
> >pt=49.45031,11.077721
> >d=40
> >
> >fl=store
> >sort=geodist() asc
> >
> >
> >On Thu, Feb 3, 2011 at 7:46 PM, Grant Ingersoll <[hidden email]>
> >wrote:
> >
> >> Use a filter query?  See the {!geofilt} stuff on the wiki page.  That
> >>gives
> >> you your filter to restrict down your result set, then you can sort by
> >>exact
> >> distance to get your sort of just those docs that make it through the
> >> filter.
> >>
> >>
> >> On Feb 3, 2011, at 10:24 AM, Eric Grobler wrote:
> >>
> >> > Hi Erick,
> >> >
> >> > Thanks I saw that example, but I am trying to sort by distance AND
> >> specify
> >> > the max distance in 1 query.
> >> >
> >> > The reason is:
> >> > running bbox on 2 million documents with a 20km distance takes only
> >> 200ms.
> >> > Sorting 2 million documents by distance takes over 1.5 seconds!
> >> >
> >> > So it will be much faster for solr to first filter the 20km documents
> >>and
> >> > then to sort them.
> >> >
> >> > Regards
> >> > Ericz
> >> >
> >> > On Thu, Feb 3, 2011 at 1:27 PM, Erick Erickson
> >><[hidden email]
> >> >wrote:
> >> >
> >> >> Further down that very page <G>...
> >> >>
> >> >> Here's an example of sorting by distance ascending:
> >> >>
> >> >>  -
> >> >>
> >> >>  ...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
> >> >> asc<
> >> >>
> >>
> >>
> http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*
> >>&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc
> >> >>>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> The key is just the &sort=geodist(), I'm pretty sure that's
> >>independent
> >> of
> >> >> the bbox, but
> >> >> I could be wrong.
> >> >>
> >> >> Best
> >> >> Erick
> >> >>
> >> >> On Wed, Feb 2, 2011 at 11:18 AM, Eric Grobler <
> >> [hidden email]
> >> >>> wrote:
> >> >>
> >> >>> Hi
> >> >>>
> >> >>> In http://wiki.apache.org/solr/SpatialSearch
> >> >>> there is an example of a bbox filter and a geodist function.
> >> >>>
> >> >>> Is it possible to do a bbox filter and sort by distance - combine
> >>the
> >> >> two?
> >> >>>
> >> >>> Thanks
> >> >>> Ericz
> >> >>>
> >> >>
> >>
> >> --------------------------
> >> Grant Ingersoll
> >> http://www.lucidimagination.com/
> >>
> >> Search the Lucene ecosystem docs using Solr/Lucene:
> >> http://www.lucidimagination.com/search
> >>
> >>
>
>
>