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 vit <bu...@yahoo.com> on 2015/01/26 23:18:50 UTC

Showing distance in results

I have Solr 4.2
I need to calculate the distance between a point (0, 0) and lat lng in each
document. I do this
http://<host>:9081/solr/collection1/select?q={!func}dist(2, lat, lng, 0,
0)&wt=xml&indent=true

It works fine but does not show the distance, Please help.



--
View this message in context: http://lucene.472066.n3.nabble.com/Showing-distance-in-results-tp4182077.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Showing distance in results

Posted by Erick Erickson <er...@gmail.com>.
A very small bit of Googling yeilds:
https://wiki.apache.org/solr/SpatialSearch

Best,
Erick

On Mon, Jan 26, 2015 at 2:18 PM, vit <bu...@yahoo.com> wrote:

> I have Solr 4.2
> I need to calculate the distance between a point (0, 0) and lat lng in each
> document. I do this
> http://<host>:9081/solr/collection1/select?q={!func}dist(2, lat, lng, 0,
> 0)&wt=xml&indent=true
>
> It works fine but does not show the distance, Please help.
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Showing-distance-in-results-tp4182077.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Showing distance in results

Posted by Erick Erickson <er...@gmail.com>.
Did you just try just setting up the demo then trying the example? I often
find if I advance step-by-step from the example, it is much easier
to figure things out.

sfield is the name of the field containing the location information,
"store" in the examples
Both "store", and "pt" are required to be defined by the geodist() function.

dist() is a different function query with its own syntax. If you use
geodist(), you must
define pt and sfield.

Best,
Erick

On Tue, Jan 27, 2015 at 8:30 AM, vit <bu...@yahoo.com> wrote:

> Hi Erick
> I tried this link but do not see a straight forward answer.
> For example it says:
> /You can use the pseudo-field feature to return the distance along with the
> stored fields of each document by adding fl=geodist() to the request/
> So I tried:
> ...?q={!func}dist(2, lat, lng, 0, 0)&fl=geodist()&wt=xml&indent=true
> <http://>   which returnes:
> *<lst name="error">
>   <str name="msg">Error parsing fieldname: geodist - not enough
> parameters:[]</str>
>   <int name="code">400</int>
> </lst>*
>
> Also it is not clear what is sfield=store in all examples, like this:
> ...&q={!func}geodist()&sfield=store&pt=45.15,-93.85&sort=score asc <http://
> >
> So if possible could you explain this either.
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Showing-distance-in-results-tp4182077p4182284.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Showing distance in results

Posted by vit <bu...@yahoo.com>.
Hi Erick 
I tried this link but do not see a straight forward answer. 
For example it says:
/You can use the pseudo-field feature to return the distance along with the
stored fields of each document by adding fl=geodist() to the request/
So I tried:
...?q={!func}dist(2, lat, lng, 0, 0)&fl=geodist()&wt=xml&indent=true
<http://>   which returnes:
*<lst name="error">
  <str name="msg">Error parsing fieldname: geodist - not enough
parameters:[]</str>
  <int name="code">400</int>
</lst>*

Also it is not clear what is sfield=store in all examples, like this:
...&q={!func}geodist()&sfield=store&pt=45.15,-93.85&sort=score asc <http://>  
So if possible could you explain this either. 



--
View this message in context: http://lucene.472066.n3.nabble.com/Showing-distance-in-results-tp4182077p4182284.html
Sent from the Solr - User mailing list archive at Nabble.com.