Finding Solr documents that intersect with a defined Radius

回眸只為那壹抹淺笑 提交于 2020-01-07 00:36:15

问题


We are using Apache Solr 5.x, and we currently have a bunch of defined shapes. Polygons, Circles, etc. These all correspond to a document, each shape of coordinates does.

What I want to know is - is it possible to provide a circle, that is - a (lat,lng) pair along with a Radius for that circle - and then find all documents that have an intersection with that circle?

I have tried a variety of options, most recently this one:

solr_index_wkt:"IsWithin(CIRCLE((149.39999999999998 -34.92 d=0.44964028776978415))) distErrPct=0.0"

However, this results in the following error:

"msg": "Unknown Shape definition [CIRCLE((149.39999999999998 -34.92 d=0.44964028776978415))]",

Really stumped on this one.

update

the solr_index_wkt is the field that is defining the 'bounding boxes' for the polygons, circles and stuff on the indexed documents.


回答1:


I had a very similar problem and I kept banging my head against my keyboard until I found this little gem. I'm sure you're probably using solr.SpatialRecursivePrefixTreeFieldType in your schema.xml file. You need to set the format attribute to "LEGACY". It should then recognize Circle in your queries!

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
       spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"
       autoIndex="true"
       validationRule="repairBuffer0"
       format="LEGACY"
       distErrPct="0.025"
       maxDistErr="0.001"
       distanceUnits="miles" />


来源:https://stackoverflow.com/questions/39092196/finding-solr-documents-that-intersect-with-a-defined-radius

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!