How to do Polygon Spatial Search in Spring-data-solr

372 views Asked by At

I have to do a query something like below :-

fq=latlng:IsWithin(POLYGON(('23.60 71.60','28.65 71.68','28.60 72.61','28.63 72.65')))

Now I got stuck here in how to do this query using Spring-Data-Solr where I have function like

public List<Hotel> getHotelsInsidePolygon(Point... points);

It will be helpful if anyone tells how to proceed

1

There are 1 answers

0
Swaraj On BEST ANSWER

Got this one :-

Thing to change in Solr for polygon search to work are

  1. Add JTS jars in deployed solr war WEB-INF/lib
  2. Change field type of latlng from "location" to "location_rpt"
  3. Modify location_rpt field type as below

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />

  1. Add location data to index it and the polygon query will work.