数据导入Apache Solr到Datastax Solr - DateFormat Transformer DIH

时间:2017-03-31 20:32:05

标签: solr datastax dataimporthandler dih

我正在尝试使用DIH将数据从Apache Solr导入Datastax Solr。我能够获取文档,但是当DIh尝试创建文档时,我在日期字段中得到以下错误:

org.apache.solr.common.SolrException: Invalid Date String:'Thu Jun 08 16:23:00 PDT 2017'
at org.apache.solr.schema.DateField.parseMath(DateField.java:182)
at com.datastax.bdp.search.solr.core.types.V1TypeMapper.formatToCassandraType(V1TypeMapper.java:166)
at com.datastax.bdp.search.solr.core.types.V2TypeMapper.formatToCassandraType(V2TypeMapper.java:101)
at com.datastax.bdp.search.solr.Cql3CassandraRowWriter.write(Cql3CassandraRowWriter.java:170)
at com.datastax.bdp.search.solr.handler.update.CassandraDirectUpdateHandler.addDoc(CassandraDirectUpdateHandler.java:161)
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.versionAdd(DistributedUpdateProcessor.java:595)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:435)
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
at org.apache.solr.update.processor.AbstractDefaultValueUpdateProcessorFactory$DefaultValueUpdateProcessor.processAdd(AbstractDefaultValueUpdateProcessorFactory.java:94)
at org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:70)
at org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:235)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:504)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:408)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:323)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:231)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:476)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:457)

我在DIH中使用DateFormat变换器,但似乎没有效果。 DateFormat转换器将日期字符从Apache Solr转换为' dateTimeFormat'中指定的格式。在创建要在Datastax Solr中索引的文档之前。

<dataConfig>
  <document>
     <entity name="sep_byOrderNumber" processor="SolrEntityProcessor" query="OrderNumber:${dataimporter.request.OrderNumberList}" rows="${dataimporter.request.batchSize}" url="${dataimporter.request.urlSource}" transformer="DateFormatTransformer" loglevel="debug">
      <field column="OrderCreateDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss.SSSZ" />
     </entity>
  </document>
</dataconfig>

有人可以帮助确定问题吗?

1 个答案:

答案 0 :(得分:0)

将dateTimeFormat更改为:EEE MMM dd HH:mm:ss z yyyy

Letter  Date or Time Component             Presentation Examples
y       Year                               Year         1996; 96
M       Month in year (context sensitive)  Month        July; Jul; 07
d       Day in month                       Number       10
E       Day name in week                   Text         Tuesday; Tue
H       Hour in day (0-23)                 Number       0
m       Minute in hour                     Number       30
s       Second in minute                   Number       55
z       Time zone                          Time zone    Pacific Standard Time; PST; GMT-08:00

来源:http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html