我必须做一个如下所示的查询:-
fq=latlng:IsWithin(POLYGON(('23.60 71.60','28.65 71.68','28.60 72.61','28.63 72.65')))
现在我陷入了如何使用 Spring-Data-Solr 进行此查询的困境,其中我有这样的函数
public List<Hotel> getHotelsInsidePolygon(Point... points);
如果有人告诉如何进行,这将很有帮助
得到了这个:-
在 Solr 中要更改的内容以使多边形搜索正常工作是
- 在已部署的 solr war 中添加 JTS jar WEB-INF/lib
- 将 latlng 的字段类型从"位置"更改为"location_rpt"
- 修改location_rpt字段类型,如下所示
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees"
/>
- 添加位置数据以为其编制索引,多边形查询将起作用。