Solr: Spatial Search

1. schema

 

 

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
        geo="true" distErrPct="0.025" maxDistErr="0.001"  distanceUnits="kilometers"/>

 

 

 

<field name="location_rpt" type="location_rpt" indexed="true" stored="true" multiValued="true"/>

 

 

 

data import

 

 

select id, name, latitude, longtitude,CONCAT_WS(',',longtitude,latitude) as location_rpt, commodities, credit, created_at from seller

 

 

There is a error when import data from mysql to solr

WARN  - 2015-06-26 06:37:30.819; [   testcore2] org.apache.solr.handler.dataimport.SolrWriter; Error creating document : SolrInputDocument(fields: [id=5, name=红旗连锁, created_at=2015-06-18 15:34:34.0, longtitude=104.072276, commodities=烟、酒、饮料、零食、茶叶, latitude=30.550858, credit=90, location_rpt=104.072276,30.550858, _version_=1505021815232135168])
org.apache.solr.common.SolrException: Can't parse point '104.072276,30.550858' because: Bad Y value 104.072276 is not in boundary Rect(minX=-180.0,maxX=180.0,minY=-90.0,maxY=90.0)

 

solution:

select id, name, latitude, longtitude,CONCAT_WS(',',latitude,longtitude) as location_rpt, commodities, credit, created_at from seller

 

change latitude,longtitude two fields places to statisfy the command

Points are indexed just as they are in Solr 3 spatial:

     <field name="geo">43.17614,-90.57341</field> 

If a comma is omitted, then it is in x-y (lon-lat) order:

     <field name="geo">-90.57341 43.17614</field>

 

"lon lat" or "lat,lon" format
 
 
{!geofilt}&sfield=location_rpt&pt=30.55078,104.072941&d=2&sort=geodist() asc
 
-----------------------------
add JTS
#cp jts-1.13.jar  /path/to/WEB-INF/lib
#cd /path/to/WEB-INF/lib
jar -uf /opt/solr/server/webapps/solr.war WEB-INF/lib/jts-1.13.jar
 
 
 

http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值