Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to sort Solr Geospatial search results

How can we have Solr 3.6.1 return the Geospatial search results both filtered by bbox and sorted by distance?

I tried appending a &sort=geodist() asc to the URL as stated in the Solr docs, but I get the error:

sort param could not be parsed as a query, and is not a field that exists in the index: geodist()

Query URL with sort & bbox (NOT Working)

http://localhost8080/solr/select?wt=json&indent=true
&q=*:*
&fl=id,latlng
&fq={!bbox%20pt=42.352455,-71.048069%20sfield=latlng%20d=5}
&sort=geodist() asc

Query URL with sort (Works)

http://localhost:8080/solr/select?wt=json&indent=true
&fl=id,latlng
&q=*:*
&sfield=latlng
&pt=42.352455,-71.048069
&sort=geodist()%20asc

Query URL with bbox (Works)

http://localhost8080/solr/select?wt=json&indent=true
&q=*:*
&fl=id,latlng
&fq={!bbox%20pt=42.352455,-71.048069%20sfield=latlng%20d=5}

How can I have both bbox filtering and sort the results by distance (geodist())?

like image 336
Nyxynyxx Avatar asked Sep 28 '12 03:09

Nyxynyxx


1 Answers

Simply pull out the 'pt' and 'sfield' local-params you have into top-level query parameters, just as you did with the working sort query. Your fq will be just {!bbox d=5}

like image 123
David Smiley Avatar answered Sep 23 '22 13:09

David Smiley