为索引的多边形返回不正确的距离

Incorrect distance returned for indexed polygone shape

我在 Solr 查询中使用 geodist()。关注此 select?=&fl=*,_dist_:geodist()&fq={!geofilt d=30444}&indent=on&pt=50.53,-9.5722616&q=*:*&sfield=geo&spatial=true&wt=json 但是,距离计算似乎不起作用。这是一个示例查询,其中 pt 距离 POLYGON 几百公里。计算出的geodist总是20015.115 .

的问题

这是我的查询回复:

{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "q":"*:*",
      "pt":"50.53,-9.5722616",
      "indent":"on",
      "fl":"*,_dist_:geodist()",
      "fq":"{!geofilt d=30444}",
      "sfield":"geo",
      "spatial":"true",
      "wt":"json"}},
  "response":{"numFound":3,"start":0,"docs":[
      {
        "id":"1",
        "document_type_id":"1",
        "geo":["POLYGON ((3.837490081787109 43.61234105514181, 3.843669891357422 43.57877424689641, 3.893280029296875 43.57205863840097, 3.9458084106445312 43.58872191986938, 3.921947479248047 43.62762639320158, 3.8663291931152344 43.63321761913266, 3.837490081787109 43.61234105514181))"],
        "_version_":1689241382273679360,
        "timestamp":"2021-01-18T16:08:40.484Z",
        "_dist_":20015.115},
      {
        "id":"4",
        "document_type_id":"4",
        "geo":["POLYGON ((-0.94482421875 45.10454630976873, -0.98876953125 44.6061127451739, 0.06591796875 44.134913443750726, 0.32958984375 45.1510532655634, -0.94482421875 45.10454630976873))"],
        "_version_":1689244486784253952,
        "timestamp":"2021-01-18T16:58:01.177Z",
        "_dist_":20015.115},
      {
        "id":"8",
        "document_type_id":"8",
        "geo":["POLYGON ((-2.373046875 48.29781249243716, -2.28515625 48.004625021133904, -1.5380859375 47.76886840424207, -0.32958984375 47.79839667295524, -0.5712890625 48.531157010976706, -2.373046875 48.29781249243716))"],
        "_version_":1689252312264998912,
        "timestamp":"2021-01-18T19:02:24.137Z",
        "_dist_":20015.115}]
  }}

这是我的 solr 字段类型定义:

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" maxDistErr="0.001" 

spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory" 
validationRule="repairBuffer0"
distErrPct="0.025"
distanceUnits="kilometers"
autoIndex="true"/>

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

这是我索引多边形的方式:

{
  "id": 12,
  "document_type_id": 12,
  "geo": "POLYGON ((3.77105712890625 43.61171961774284, 3.80401611328125 43.57939602461448, 3.8610076904296875 43.59580863402625, 3.8603210449218746 43.61519958447072, 3.826675415039062 43.628123412124616, 3.7827301025390625 43.63110543935801, 3.77105712890625 43.61171961774284))"
}

我正在使用 Solr 6.6,我发现了 2 个与此相关的问题:

这可能是什么原因?

score=distance(或其他类似距离的选项)用于索引 RPT 中的点或使用 BBoxField 的框(矩形)。为此它有效。如果在 RPT 中索引非点数据,结果将是错误的,geodist 会 return 总是 20015.115

最好的快速解决方案是添加另一个具有 location 类型的字段并通过 geodist 执行距离计算,例如:

<field name="geo" type="location_rpt" multiValued="true" indexed="true" stored="true"/>
<field name="geo_for_disatance" type="location" indexed="true" required="false" stored="false"/>