elasticsearch - 弹性重新索引日期格式太短
问题描述
尝试重新索引索引,因为日期字段的格式已更改。格式从
...
"start_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
...
至
...
"start_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
...
我尝试将我的索引重新索引为 tmp 索引,但它会引发以下错误:
"cause": {
"type": "mapper_parsing_exception",
"reason": "failed to parse [start_date]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Invalid format: \"2019-01-30 13:03\" is too short"
}
},
所以,现在我有一个大问题。如何更改我的日期字段的格式?还有另一种不重新索引的选择吗?
解决方案
由于格式更改,您需要做的是附加:00
到您的日期字段以匹配新格式:
POST _reindex
{
"source": {
"index": "oldindex"
},
"dest": {
"index": "newindex"
},
"script": {
"source": "ctx._source.start_date = ctx._source.start_date + ':00';"
}
}
推荐阅读
- html - 如何将每个孩子与第 n 个孩子同时定位在 flex/grid/whatever 中?
- javascript - 类型'{ props: ReactNode; 上不存在属性'className' }'
- android - Spannable String Builder不应用字体
- html - 文字装饰:无;当父元素显示为 flex 时不起作用
- reactjs - IONIC React 无限滚动
- flutter - 如何在运行集成测试时指定构建变体?
- javascript - 用Javascript从PHP数据库访问表
- java - 使用度量 spring_cloud_stream_binder_kafka_offset 进行 kafka 滞后
- php - 订单状态更改时的 WooCommerce 严重错误
- html - 为什么 transform-origin: bottom 不起作用?