没有合适的资源?快使用搜索试试~ 我知道了~
首页基于java-solr-geo空间坐标搜索、距离排序、分页
资源详情
资源评论
资源推荐

基于 solr-geo 空间坐标搜索
1、Solr 的 schema.xml 配置 定义坐标 field
定义距离 eld,type 类型为 location_rpt
<field name="location" type="location_rpt" indexed="true"
stored="true"/>
这里重点是 location,它的 type 是 location_rpt,它在 Solr 中的定义如下:
<fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType" geo="true"
distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
geo
默认为 true,值为 true 的情况下坐标基于球面坐标系,采用 Geohash 的方式;
值为 false 的情况下坐标基于 2D 平面的坐标系,采用 Euclidean/Cartesian 的方式
2、Solr 的 data-config.xml 配置 建立索引
这里使用“经度 纬度”这样的字符串格式将经纬度索引到 location 字段中。
<!-- 坐标 -->
<entity name="userLocation"
query="SELECT CONCAT(coordinate_x,' ',coordinate_y)
location
FROM tc_user_location WHERE mid='${skill.mid}'">
<field column="location" name="location" />
</entity>

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0