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 Varun Gupta <va...@gmail.com> on 2014/03/17 14:28:29 UTC

Doing spatial search on multiple location points

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

Re: Doing spatial search on multiple location points

Posted by "Smiley, David W." <ds...@mitre.org>.
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" <va...@gmail.com> 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. <ds...@mitre.org>
>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" <va...@gmail.com> 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
>>
>>


Re: Doing spatial search on multiple location points

Posted by Varun Gupta <va...@gmail.com>.
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. <ds...@mitre.org> 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" <va...@gmail.com> 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
>
>

Re: Doing spatial search on multiple location points

Posted by "Smiley, David W." <ds...@mitre.org>.
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" <va...@gmail.com> 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