First we need to configure field type in managed-schema.xml or schema.xml:
<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true"/>
There are mainly four field types available in Solr that support spatial search:
- LatLonPointSpatialField: The most commonly used field type and an alternative to LatLonType (deprecated) for latitude—and longitude-based search.
- LatLonType: Its non-geodetic twin PointType field type, and this one is deprecated now.
- SpatialRecursivePrefixTreeFieldType: RPT supports more advanced search features, such as polygons and heatmaps. RptWithGeometrySpatialField is derived from RPT. It is used for geography-based searches. Sorting and boosting are not supported.
- BBoxField: Used to search a bounding box. It supports sorting and boosting.