How to get distance in geological prospecting Solr 4?

I play with the new Solr 4 geospatial search. As in the example from http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 I am trying to get these results:

http://localhost:8983/solr/allopenhours/select? &q=foobar &fq=geo:%22Intersects(Circle(54.729696,-98.525391%20d=0.08992))%22 &q={!%20score=distance} &fl=*,score 

But that will not work. How can I get distance and score fields in a result set?

+6
source share
2 answers

According to the Spatial Search - Distance Return link, you can change your field parameter to do one of the following:

  • &fl=*,score,geodist()
  • &fl=*,score,_dist_:geodist() - this number will return the distance in the alias _dist_
+7
source

Page gave the answer correctly. However, the error is displayed depending on the given request.

Error parsing fieldname: geodist - not enough parameters:[]

the surveyor needs sfield (a field that contains space in the document) and pt (the center point of the circle). If he cannot find any of them, he will display a displayed error.

Or add these two to the URL

 &pt=52.373,4.899&sfield=store&fl=_dist_:geodist() 

Or add two (or actually 3: pt , lat and lon ) to the geodist() function call:

 &fl:_dist_:geodist(store,52.373,4.899) 

Please note that in the first case, if your request has additional geo-functions (for example, geofilt ), pt and sfield are used for this (if it is not canceled locally)

+4
source

All Articles