请帮助解决此错误..
MapperParsingException[failed to parse]; nested: IllegalArgumentException[mapper [fareDetails.result.originDestinationOptions.flightSegments.fareDetails.taxDetails.farePrice] of different type, current_type [double], merged_type [long]];
at org.elasticsearch.index.mapper.DocumentParser.innerParseDocument(DocumentParser.java:163)
at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:79)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:304)
at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:547)
at org.elasticsearch.index.shard.IndexShard.prepareIndexOnPrimary(IndexShard.java:529)
at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:211)
at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:223)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:157)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:65)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:595)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:263)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:260)
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:350)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
因为我在该对象上使用了bigdecimal类型而没有添加anotation @Field(type = FieldType.Double)
有没有办法为bigdecimal配置默认的FieldType.Double?或者我们需要添加每个bigdecimal的字段anotation
答案 0 :(得分:1)
问题在于我的deserealization jackson ..修复添加此
public class BigDecimalMoneyDeserializer扩展了JsonDeserializer {
@Override
public BigDecimal deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
return jp.getDecimalValue().setScale(2, BigDecimal.ROUND_HALF_UP);
}
}