Spatial Filters:
geofilt
&q=*:*&fq={!geofilt sfield=store}&pt=45.15,-93.85&d=5
all the results within the circle of the given radius around the initial point
bbox
&q=*:*&fq={!bbox sfield=store}&pt=45.15,-93.85&d=5.
all the results in the box
specify large distErrPct value , the filter will run faster
arbitrary rectangle
RPT support
solr post filter
&q=...mykeywords...&fq=...someotherfilters...&fq={!geofilt cache=false cost=100}&sfield=store&pt=45.15,-93.85&d=5
distance function queries
geodist,dist,hsin,sqedist
geodist
sort result by distance asc
&q=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist asc
return distance as the document score
&q={!func}geodist()&sfield=store&pt=45.15,-93.85&sort=score+asc
More examples
use as a sub-query to expand the search results
Here we will query for results in Jacksonville, Florida, or within 50 kilometers of 45.15,-93.85 (near Buffalo, Minnesota):
&q=*:*&fq=(state:"FL" AND city:"Jacksonville") OR {!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist()+asc
facet by distance
To facet by distance, you can use the Frange query parser:
&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange l=0 u=5}geodist()&facet.query={!frange l=5.001 u=3000}geodist()
There are other ways to do it too, like using a {!geofilt} in each facet.query.
The latter is the only way to choose a predicate other than Intersects. For example:
&q={!field f=bbox}Contains(ENVELOPE(-10, 20, 15, 10))
Now to sort the results by one of the relevancy modes, use it like this:
&q={!field f=bbox score=overlapRatio}Intersects(ENVELOPE(-10, 20, 15, 10)) You can also use&debug=results to see useful score computation info.