You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2011/07/30 17:42:02 UTC

[Solr Wiki] Update of "SpatialSearch" by YonikSeeley

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "SpatialSearch" page has been changed by YonikSeeley:
http://wiki.apache.org/solr/SpatialSearch?action=diff&rev1=65&rev2=66

Comment:
pseudofield to return distance

   . [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist()%20asc|...&q=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist() asc]]
  
  == Returning the distance ==
- Returning distances (and any arbitrary function query value) is currently under development. As a temporary workaround, it's possible to obtain distances by using geodist or geofilt as the only scoring part of the main query.
+ <!> [[Solr4.0]]
+ 
+ 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.  Use an alias like '''fl=_dist_:geodist()''' to make the distance come back in the '''_dist_''' pseudo-field instead.  Here is an example of sorting by distance ascending and returning the distance for each document in '''_dist_'''.
+ 
+  . [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()%20asc&fl=_dist_:geodist()|...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist() asc&&fl=_dist_:geodist()]]
+ 
+ As a temporary workaround for older Solr versions, it's possible to obtain distances by using geodist or geofilt as the only scoring part of the main query.
  
  = Other Use Cases =
  == How to combine with a sub-query to expand results ==