地理字段的 Solr DataImportHandler 问题

Solr DataImportHandler issue with geo fields

我运行正在尝试使用 DataImportHandler 从 MySQL 导入位置数据时遇到问题。对我的一个子实体的查询是:

SELECT [...] AS data, AsText(data_geo) AS data_geo FROM [table] WHERE [conditions]

我运行查询并验证输出看起来正确:

'128 Wall St, New Haven, CT 06511, USA', 'POINT(-72.92847010000003 41.31160920000001)'

但是,当我尝试 运行 导入时,出现以下异常:

SolrWriter.upload(73) | Error creating document : SolrInputDocument(fields: [[...], data=128 Wall St, New Haven, CT 06511, USA, data_geo=[B@23bcddc0, _version_=1573858358394355712])
org.apache.solr.common.SolrException: Point must be in 'lat, lon' or 'x y' format: [B@23bcddc0
        at org.apache.solr.util.SpatialUtils.parsePointSolrException(SpatialUtils.java:113)
        at org.apache.solr.schema.AbstractSpatialFieldType.parseShape(AbstractSpatialFieldType.java:239)
        at org.apache.solr.schema.AbstractSpatialFieldType.createFields(AbstractSpatialFieldType.java:201)
        at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:48)
        at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:123)
        at org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:83)
        at org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:237)
        at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:163)
        at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
        at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:955)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:1110)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:706)
        at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:104)
        at org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:71)
        at org.apache.solr.handler.dataimport.DataImportHandler.upload(DataImportHandler.java:259)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:524)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:414)
        at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:329)
        at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:232)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:416)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:480)
        at org.apache.solr.handler.dataimport.DataImporter.run(DataImporter.java:461)
Caused by: com.spatial4j.core.exception.InvalidShapeException: Point must be in 'lat, lon' or 'x y' format: [B@23bcddc0
        at org.apache.solr.util.SpatialUtils.parsePoint(SpatialUtils.java:74)
        at org.apache.solr.util.SpatialUtils.parsePointSolrException(SpatialUtils.java:108)
        ... 22 more

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"
        autoIndex="true"
        geo="true"
        distErrPct="0.025"
        maxDistErr="0.001"
        distanceUnits="kilometers" />

我是 运行宁 Solr 5.2.1

知道它为什么要尝试使用 Java 对象哈希来导入地理字段吗?

谢谢!

我在此处的 Solr 常见问题解答中找到了解决方案:

https://wiki.apache.org/solr/DataImportHandlerFaq#line-92

我不得不将 AsText 的输出转换为 CHAR,尽管该文档还提供了另外两个解决方案。