Now that we know the features supported by Solr for spatial search, let us see how indexing should be done for spatial search. We will need to index the coordinates for point, circle, rectangle, and other spatial representations in Solr as documents before we execute a search for them. Every geographical point is represented as latitude and longitude with the format lat,lon
.
We saw points being indexed in the last section in our location.csv
file. They are indexed in the lat,lon format:
<field name="store">28.570485,77.324713</field>
The points can be indexed in the lat-lon format by omitting the comma:
<field name="store">28.570485 77.324713</field>
We saw that Solr also supports different geometrical shapes such as rectangle, circle, and polygon. Let us learn how to index these.
In order to index a rectangle, we need the two points that form the starting and the ending points of the rectangle. Consider a two-dimensional coordinate system with...