使用输入点进行Solr空间搜索并查询其中的多边形

use*_*163 4 search solr point polygon geospatial

我有一些在Solr索引的多边形.是否可以使用点(lat,lon)查询并查看哪个多边形内部有该点?

use*_*821 7

是的,这是可能的,并在此处描述:http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 您的Solr版本必须为4或更高,您必须导入JTS jar文件,您可以从http:// sourceforge获取. net/projects/jts-topo-suite / 您必须定义fieldType为location_rpt的字段

<fieldType name="location_rpt"   class="solr.SpatialRecursivePrefixTreeFieldType"
           spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
           distErrPct="0.025"
           maxDistErr="0.000009"
           units="degrees"
        />
Run Code Online (Sandbox Code Playgroud)

在schema.xml中.然后你必须索引多边形,如:

<field name="geo">POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))</field>
Run Code Online (Sandbox Code Playgroud)

但我认为你已经这样做了,因为你写道你已经将它们编入索引.

对于查询,您只需使用过滤器查询fq=geo:"Intersects(10.12 50.02)"位置10.1250.02表示点的纬度和经度.