You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Sanders, Marshall (CAI - Atlanta)" <Ma...@coxautoinc.com> on 2019/07/23 17:49:45 UTC

Solr Geospatial Polygon Indexing/Querying Issue

We’re trying to index a polygon into solr and then filter/calculate geodist on the polygon (ideally we actually want a circle, but it looks like that’s not really supported officially by wkt/geojson and instead you have to switch format=”legacy” which seems like something that might be removed in the future so don’t want to rely on it).

Here’s the info from schema:
<field name="latlng" type="location_rpt" indexed="true" stored="true" multiValued="true"/>

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


We’ve tried indexing some different data, but to keep it as simple as possible we started with a triangle (will eventually add more points to approximate a circle).  Here’s an example document that we’ve added just for testing:

{
"latlng": ["POLYGON((33.7942704 -84.4412613, 33.7100611 -84.4028091, 33.7802888 -84.3279648, 33.7942704 -84.4412613))"],
"ID": "284598223"
}


However, it seems like filtering/distance calculations aren’t working (at least not the way we are used to doing it for points).  Here’s an example query where the pt is several hundred kilometers away from the polygon, yet the document still returns.  Also, it seems that regardless of origin point or polygon location the calculated geodist is always 20015.115

Example query:
select?d=1&fl=ID,latlng,geodist()&fq=%7B!geofilt%7D&indent=on&pt=33.9798087,-94.3286133&q=*:*&sfield=latlng&wt=json

Example documents coming back anyway:
"docs": [
{
"latlng": ["POLYGON((33.7942704 -84.4412613, 33.7100611 -84.4028091, 33.7802888 -84.3279648, 33.7942704 -84.4412613))"],
"ID": "284598223",
"geodist()": 20015.115
},
{
"latlng": ["POLYGON((33.7942704 -84.4412613, 33.7100611 -84.4028091, 33.7802888 -84.3279648, 33.7942704 -84.4412613))"],
"ID": "284600596",
"geodist()": 20015.115
}
]


Anyone who has experience in this area can you point us in the right direction about what we’re doing incorrectly with either how we are indexing the data and/or how we are querying against the polygons.

Thank you,


--
Marshall Sanders
Principal Software Engineer
Autotrader.com
marshall.sanders2@coxautoinc.com<ma...@coxautoinc.com>