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()
)?
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With