Doing spatial search on multiple location points

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

Doing spatial search on multiple location points

Varun Gupta-2
Hi,

I am trying to find out if solr supports doing a spatial search on multiple
location points. Basically, while querying solr, I will be giving multiple
lat-long points and solr will be returning documents which are closer to
any of the given points.

If this is not possible, is there any way to make it work without hitting
solr for each of the lat-long and then collating results.

Thanks in advance.

--
Varun Gupta
Reply | Threaded
Open this post in threaded view
|

Re: Doing spatial search on multiple location points

David Smiley
Absolutely.  The most straight-forward approach is to use the default
query parser comprised of OR clauses of geofilt query parser based
clauses.  Another way to do it in Solr 4.7 that is probably faster is to
use WKT with the custom “buffer" extension:
myLocationRptField:"BUFFER(MULTIPOINT(x y, x y, x y, x y), d)
distErrPct=0" (whereas ‘d’ is distance in degrees, not km).

~ David

On 3/17/14, 9:28 AM, "Varun Gupta" <[hidden email]> wrote:

>Hi,
>
>I am trying to find out if solr supports doing a spatial search on
>multiple
>location points. Basically, while querying solr, I will be giving multiple
>lat-long points and solr will be returning documents which are closer to
>any of the given points.
>
>If this is not possible, is there any way to make it work without hitting
>solr for each of the lat-long and then collating results.
>
>Thanks in advance.
>
>--
>Varun Gupta

Reply | Threaded
Open this post in threaded view
|

Re: Doing spatial search on multiple location points

Varun Gupta-2
Hi David,

Thanks for the quick reply.

As I haven't migrated to 4.7 (I am still using 4.6), I tested using OR
clause with multiple geofilt query based phrases and it seems to be working
great. But I have one more question: How do I boost the score of the
matching documents based on geodist? How will I get the geodist based on
the closest matching lat-long point.

Thanks in advance.

--
Varun Gupta

On Mon, Mar 17, 2014 at 7:27 PM, Smiley, David W. <[hidden email]> wrote:

> Absolutely.  The most straight-forward approach is to use the default
> query parser comprised of OR clauses of geofilt query parser based
> clauses.  Another way to do it in Solr 4.7 that is probably faster is to
> use WKT with the custom "buffer" extension:
> myLocationRptField:"BUFFER(MULTIPOINT(x y, x y, x y, x y), d)
> distErrPct=0" (whereas 'd' is distance in degrees, not km).
>
> ~ David
>
> On 3/17/14, 9:28 AM, "Varun Gupta" <[hidden email]> wrote:
>
> >Hi,
> >
> >I am trying to find out if solr supports doing a spatial search on
> >multiple
> >location points. Basically, while querying solr, I will be giving multiple
> >lat-long points and solr will be returning documents which are closer to
> >any of the given points.
> >
> >If this is not possible, is there any way to make it work without hitting
> >solr for each of the lat-long and then collating results.
> >
> >Thanks in advance.
> >
> >--
> >Varun Gupta
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Doing spatial search on multiple location points

David Smiley
Varun,

You could use a function query involving “min” with a comma-separated list
of geodist clauses.

See https://cwiki.apache.org/confluence/display/solr/Spatial+Search
“Boost Nearest Results”.  You’d replace the geodist() in there with
min(geodist(45.15,-93.85),geodist(50.2,22.3),…)   (etc.)

~ David

On 3/18/14, 2:59 AM, "Varun Gupta" <[hidden email]> wrote:

>Hi David,
>
>Thanks for the quick reply.
>
>As I haven't migrated to 4.7 (I am still using 4.6), I tested using OR
>clause with multiple geofilt query based phrases and it seems to be
>working
>great. But I have one more question: How do I boost the score of the
>matching documents based on geodist? How will I get the geodist based on
>the closest matching lat-long point.
>
>Thanks in advance.
>
>--
>Varun Gupta
>
>On Mon, Mar 17, 2014 at 7:27 PM, Smiley, David W. <[hidden email]>
>wrote:
>
>> Absolutely.  The most straight-forward approach is to use the default
>> query parser comprised of OR clauses of geofilt query parser based
>> clauses.  Another way to do it in Solr 4.7 that is probably faster is to
>> use WKT with the custom "buffer" extension:
>> myLocationRptField:"BUFFER(MULTIPOINT(x y, x y, x y, x y), d)
>> distErrPct=0" (whereas 'd' is distance in degrees, not km).
>>
>> ~ David
>>
>> On 3/17/14, 9:28 AM, "Varun Gupta" <[hidden email]> wrote:
>>
>> >Hi,
>> >
>> >I am trying to find out if solr supports doing a spatial search on
>> >multiple
>> >location points. Basically, while querying solr, I will be giving
>>multiple
>> >lat-long points and solr will be returning documents which are closer
>>to
>> >any of the given points.
>> >
>> >If this is not possible, is there any way to make it work without
>>hitting
>> >solr for each of the lat-long and then collating results.
>> >
>> >Thanks in advance.
>> >
>> >--
>> >Varun Gupta
>>
>>