我设置了 Solr 4.3.0,并且正在尝试将 SpatialRecursivePrefixTreeFieldType 用于空间字段。数据来自 MySQL 几何字段,SQL 查询使用AsText()
. 基本查询如下所示:
SELECT AsText(data_geo) as data_geo FROM table;
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" />
当我执行基本的非地理过滤查询时,响应如下所示:
{
"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
}
]
}
}
添加 {!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": []
}
}
有谁知道这里发生了什么?我不知道问题是在索引方面还是在查询方面;我找不到任何关于将 MySQL 与 Solr DataImportHandler 和新的 SpatialRecursivePrefixTreeFieldType 一起使用的文档。
谢谢!