cdchenli 发表于 2016-12-14 10:34:01

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: )
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
页: [1]
查看完整版本: Solr: Spatial Search