0

我在尝试使用 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$1.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$1.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 对象散列的东西来导入地理字段吗?

谢谢!

4

1 回答 1

0

我在这里的 Solr FAQ 中找到了解决方案:

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

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

于 2017-09-20T14:49:08.120 回答