Solr v4.4地理感知

来源:互联网 发布:电脑视频剪切软件 编辑:程序博客网 时间:2024/06/05 05:04

1.1.        配置schema.xml

<fieldType name="location_rpt"   class="solr.SpatialRecursivePrefixTreeFieldType"

              spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"

               distErrPct="0.025"

               maxDistErr="0.000009"

 

               units="degrees"/>

 说明:

1.       需要加入jts-1.8.jar包,本地路径:E:\tomcat7\webapps\solr\WEB-INF\lib

2.       distErrPct:值范围为0.0 – 0.5,对于圆、多边形等表示中心点到边界之间距离的精度值,默认0.025,即容许有有2.5%的误差。

3.       maxDistErr:精确度,默认是1

1.2.        上传地理数据至solr

doc.addField("location", gpsX + " " + gpsY);

location的数据格式是:经度 维度,中间必须有空格。

1.3.        无排序查询

fq={!geofilt sfield=location pt=51.507222,0.128621 d=3.5}

 

说明:

1.       使用fq过滤查询

2.       sfield参数为schema.xml配置的field name

3.       pt是:维度,经度,和上传地理数据的格式相反

4.       d是以pt为中心点的半径值,单位是公里

1.4.        排序查询

fl=*,score&sort=score asc&q={!geofilt score=distance sfield= location pt=54.729696,-98.525391 d=10}

 


0 0
原创粉丝点击