solr 的 Spatial Search

solr Spatial Search 

schema.xml  定义

<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

<!--field 的定义 location 是用来存放经度和维度, 格式:39.885003,116.384099-->
<field name="location" type="location" indexed="true" stored="true"/>

<dynamicField name="*_coordinate" type="double" indexed="true" stored="true" multiValued="false"/>


在dataimport 的时候需要用到TemplateTransformer
db-data-config.xml
filed的配置如下
<field name="location"   column="location" template="${poi.latitudes },${poi.longitudes}" />

查询一公里内的
http://127.0.0.1:8080/solr/poi/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&&fq={!geofilt%20sfield=location}&pt=39.885,116.384034&d=1

更多参考
http://wiki.apache.org/solr/SpatialSearch
http://wiki.apache.org/solr/SpatialSearchDev

猜你喜欢

转载自chengqianl.iteye.com/blog/1545021