简体   繁体   English

Solr SpatialRecursivePrefixTreeFieldField和MySQL DIH

[英]Solr SpatialRecursivePrefixTreeFieldType and MySQL DIH

I have Solr 4.3.0 set up and I'm trying to use the SpatialRecursivePrefixTreeFieldType for a spatial field. 我已经设置了Solr 4.3.0,并且试图将SpatialRecursivePrefixTreeFieldType用于空间字段。 The data comes from a MySQL geometry field, and the SQL query returns the data for that field using AsText() . 数据来自MySQL几何字段,SQL查询使用AsText()返回该字段的数据。 The basic query looks like this: 基本查询如下所示:

SELECT AsText(data_geo) as data_geo FROM table;

The data_geo field is defined in schema.xml as: data.geo字段在schema.xml中定义为:

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

<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" 
    spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
    geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />

When I perform a basic non-geofiltered query, the response looks like this: 当我执行基本的非地理过滤查询时,响应如下所示:

{
  "responseHeader": {
    "status": 0,
    "QTime": 0,
    "params": {
    "indent": "true",
    "q": "*:*",
    "_": "1384375755970",
    "wt": "json"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "date_modified": "2013-11-13T16:53:57Z",
        "id": "165733_0_1",
        "data_geo": "POINT(43.87910249999999 -103.4590667)",
        "_version_": 1451618631810023400
      }
    ]
  }
}

Adding a {!geofilt} eliminates all results, even though the point above is within 10km of the point I'm filtering on: 添加{!geofilt}会消除所有结果,即使上面的点在我要过滤的点的10公里之内:

{
  "responseHeader": {
    "status": 0,
    "QTime": 1,
    "params": {
      "indent": "true",
      "q": "*:*",
      "_": "1384376149059",
      "wt": "json",
      "fq": "{!geofilt pt=43.879103,-103.459067 sfield=data_geo d=10}"
    }
  },
  "response": {
    "numFound": 0,
    "start": 0,
    "docs": []
  }
}

Does anyone know what's going on here? 有人知道这是怎么回事吗? I don't know if the issue is on the indexing side or the query side; 我不知道问题出在索引方面还是在查询方面。 I couldn't find any documentation on using MySQL with the Solr DataImportHandler and the new SpatialRecursivePrefixTreeFieldType. 我找不到与Solr DataImportHandler和新的SpatialRecursivePrefixTreeFieldType一起使用MySQL的任何文档。

Thanks! 谢谢!

Easy: The problem is that you are indexing your data with latitudes and longitudes reversed. 容易:问题在于您正在以相反的纬度和经度索引数据。 If you choose the WKT format as you have done, then it's "POINT(XY)" order. 如果选择了WKT格式,则为“ POINT(XY)”顺序。 You may also do "Y, X" if that suits you. 如果合适的话,您也可以选择“ Y,X”。 I'm surprised Solr (actually Spatial4j) didn't complain about you using a Y value of -103 which is clearly out of bounds. 我很惊讶Solr(实际上是Spatial4j)没有抱怨您使用的Y值-103显然超出范围。 There is a boundary check. 有边界检查。 The error would be InvalidShapeException "Bad Y value -103.4590667 is not in boundary ..." (and then the boundary) 错误将是InvalidShapeException“错误的Y值-103.4590667不在边界...”(然后是边界)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM