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 Anand Henry <an...@gmail.com> on 2012/08/02 01:52:23 UTC

SOLR 3.4 GeoSpatial Query Returning distance

Hi,

In SOLR 3.4, while doing a geo-spatial search, is there a way to retrieve
the distance of each document from the specified location?

I am aware of the workaround mentioned at
http://wiki.apache.org/solr/SpatialSearch/#Returning_the_distance, however
it doesn't work for me, since search terms also have to be included as part
of the query.

Thanks,
Anand

Re: SOLR 3.4 GeoSpatial Query Returning distance

Posted by Tanguy Moal <ta...@gmail.com>.
Hi,
I've not tested it by myself but I think that can take advantage of Solr
4's pseudo fields, by adding something like :

&fl=*,geodist(),score

I think you could even pass several geodist() calls with different
parameters if you want to have the distance wrt several POIs ^-^

SOLR 4 only.

--
Tanguy

2012/8/2 Michael Kuhlmann <ku...@solarier.de>

> On 02.08.2012 01:52, Anand Henry wrote:
>
>> Hi,
>>
>> In SOLR 3.4, while doing a geo-spatial search, is there a way to retrieve
>> the distance of each document from the specified location?
>>
>
> Not that I know of.
>
> What we did was to read and parse the location field on client side and
> calculate the distance on our own using this library:
>
> http://code.google.com/p/**simplelatlng/<http://code.google.com/p/simplelatlng/>
>
> However, it's not as "nice" as getting the distance from Solr, and
> sometimes the distances seem to slightly differ - e.g. when you filter up
> to a distance of 100 km, there are cases where the client library still
> computes 100.8 km or so.
>
> But at least, it's working.
>
> -Kuli
>

Re: SOLR 3.4 GeoSpatial Query Returning distance

Posted by Michael Kuhlmann <ku...@solarier.de>.
On 02.08.2012 01:52, Anand Henry wrote:
> Hi,
>
> In SOLR 3.4, while doing a geo-spatial search, is there a way to retrieve
> the distance of each document from the specified location?

Not that I know of.

What we did was to read and parse the location field on client side and 
calculate the distance on our own using this library:

http://code.google.com/p/simplelatlng/

However, it's not as "nice" as getting the distance from Solr, and 
sometimes the distances seem to slightly differ - e.g. when you filter 
up to a distance of 100 km, there are cases where the client library 
still computes 100.8 km or so.

But at least, it's working.

-Kuli