Book Image

Apache Solr Search Patterns

By : Jayant Kumar
Book Image

Apache Solr Search Patterns

By: Jayant Kumar

Overview of this book

Table of Contents (17 chapters)
Apache Solr Search Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 sfield=store d=10}

The output in our case would remain the same as that in the figure – Stores within 10 km from our location point – shown earlier in this chapter, but the search now includes the grayed-out area, as shown in the...