java - 使用默认格式的 Elasticsearch 日期解析问题
问题描述
我的es版本是7.5.1
映射是:
"dynamic": "strict",
"properties"{
...
"memberDOB": {
"type": "date"
}
...
}
根据此链接,https ://www.elastic.co/guide/en/elasticsearch/reference/current/date.html它说:
可以自定义日期格式,但如果未指定格式,则使用默认格式:
"strict_date_optional_time||epoch_millis"
在将数据写入 es 时,纪元中的 memberDOB 值为 -3715200000,即 '1969-11-19',我遇到了这个问题: MapperParsingException [failed to parse field [memberDOB] of type [date] in document with id 'ACX03:xcxcxcxcxcxcxcxcxcxc '。字段值预览:'-3715200000']; 嵌套:NotSerializableExceptionWrapper [date_time_exception:年份的无效值(有效值-999999999 - 999999999):-3715200000]
从提到的例外情况来看,似乎纪元日期被视为 yyyy-mm-dd 格式。
我还更新了新索引中的格式"format":"strict_date_optional_time||epoch_millis"
并尝试写入,但仍然出现相同的错误。
但是当我将格式更新为 时"format":"epoch_millis"
,它可以工作。
有人可以解释为什么会发生这种情况或我在这里缺少什么(默认格式)?
解决方案
推荐阅读
- python - 在 Django 中检查另一个字段时使用值预弹出字段
- php - 直接从文件中读取变量
- python - 从元组生成随机列表,但能够选择每个项目的百分比
- c# - 如何在 Visual Studio 2019 中设置要始终复制的整个文件文件夹(或如何使文件始终默认复制)
- python - ConfigServer 防火墙阻止 PySFTP 传出连接
- laravel - Laravel 中的多用户认证系统
- python - Sublime Text 3 REPL 在运行 plt.show() 后停止接受输入
- java - 如何确定我的 Java 应用程序在哪个监视器中运行?
- vuetify.js - 在 Vuetify 中继承 prop 样式
- php - 如何在 PHP 5.6 中向 APNS 发送 http2 请求