问题遇到的现象和发生背景
用springboot整合es时,es使用的是7.9.3版本,使用的实体类映射Document的方式,由于需要关联,使用的是内嵌对象类型Nested,然后发现有多个nested对象中属性和java预设属性不一致的问题,我使用的@filed注解指明是keyword也还是一样,而且createIndex = false,elasticsearchOperations.save(对象);时,还是自动构建mapping以及插入了不正确格式的内容
问题相关代码,请勿粘贴截图
@ApiModelProperty(value = "有效期止")
@Field(type = FieldType.Keyword,name = "expirationDate")
private String expirationDate;
运行结果及报错内容
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse field [commontaxpayerList.expirationDate] of type [date] in document with id '163353740'. Preview of field's value: '-'"}],"type":"mapper_parsing_exception","reason":"failed to parse field [commontaxpayerList.expirationDate] of type [date] in document with id '163353740'. Preview of field's value: '-'","caused_by":{"type":"illegal_argument_exception","reason":"failed to parse date field [-] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"date_time_parse_exception","reason":"Failed to parse with all enclosed parsers"}}},"status":400}
我的解答思路和尝试过的方法
反复检查,字段类型和@Field注解指定的类型
我想要达到的结果
以上字段不为date的mapping,而是映射到string类型