不为失败找理由,要为成功找方法。

关于在String类型下写入"2016-09-00"报 MapperParsingException

Elasticsearch | 作者 nlp4u | 发布于2016年10月18日 | 阅读数:7683

我在更新es数据时,写入一个”2016-09-00“的字符串,到birthdate字段,该字段已定义为string , not_analyzed。却报了一个MapperParsingException的错。
另外,我已经在mapping里设置了模板,默认type为string,not_analyzed.
详细报错如下:
MapperParsingException[failed to parse [birthdata]]; nested: IllegalArgumentException[Cannot parse "1983-09-00": Value 0 for dayOfMonth must be in the range [1,30]];
at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:329)
at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:309)
at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:436)
at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:262)
at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:122)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:580)
at org.elasticsearch.index.shard.IndexShard.prepareIndexOnPrimary(IndexShard.java:559)
at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:212)
at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:224)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:158)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:66)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:639)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:279)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:271)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Cannot parse "1983-09-00": Value 0 for dayOfMonth must be in the range [1,30]
at org.joda.time.field.FieldUtils.verifyValueBounds(FieldUtils.java:234)
at org.joda.time.field.PreciseDurationDateTimeField.set(PreciseDurationDateTimeField.java:79)
at org.joda.time.format.DateTimeParserBucket$SavedField.set(DateTimeParserBucket.java:568)
at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:447)
at org.joda.time.format.DateTimeParserBucket.doParseMillis(DateTimeParserBucket.java:182)
at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:780)
at org.elasticsearch.index.mapper.core.DateFieldMapper$DateFieldType.parseStringValue(DateFieldMapper.java:362)
at org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:528)
at org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:241)
at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:321)
... 21 more


这是不是一个bug?到底是什么原因?我用的是2.3.3版本
已邀请:

gfswsry - 80后IT

赞同来自:

 你确定这个字段设置成“String”了?我在没设这个字段为string前会报这个问题,设置后就没有了!

nlp4u - hello world!

赞同来自:

问题解决了是程序字段配置错了,导致写入到新的字段里,结果映射为date类型,故报错了。
然后模板映射也只是针对string类型,做了一个not_analyzed的模板。

要回复问题请先登录注册