I have a set of data, where each entry has a lat/lon coordinate associated with it.
I have the following form:
- textfield that is converted to a lat/lon via geocoding
- 3 select fields, each allowing only a single value, and each value represents a lat/lon coordinate
I would like to return all data that has a lat/lon coordinate within a 50 mile radius of any of the lat/lon points selected in the form. What is the recommended approach to doing this with Solr?
You can use a field type
LatLonPointSpatialFieldfor indexing the lat/lon. coordinates. For example, Solr default configset defines the following in its schema, which is sufficient to enable spatial search :Then for querying, use the
geofiltquery parser in a filter query. Matching entries within a circle of the given radius around any of the (multiple) lat/lon points selected means you need to OR multiple{!geofilt}queries, one for eachpt. Note that the radial distancedmust be specified in kilometers, eg. :