Searching and filtering on a spatial index
Spatial fields in a Solr index can be searched and filtered using the {!geofilt}
and {!bbox}
query filters. These filters were introduced and are available in Solr 4.2 onward. We saw a working example of geofilt
earlier in this chapter. Let us go through some other queries that can be executed on a spatial index in Solr.
The bbox query
The working of a bbox
filter is similar to that of geofilt
, except that the former uses the bounding box of a calculated circle. The query remains the same, except that we use the {!bbox}
filter instead of the {!geofilt}
filter. To convert the earlier query to bbox
from geofilt
, we run the following query:
http://localhost:8983/solr/collection1/select/?q=*:*&fq={!bbox pt=28.643059,77.368885 ...
Get Apache Solr Search Patterns now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.