ES 7.8 能够将 long 类型的字段 reindex 成 keyword 类型的字段么?
Elasticsearch | 作者 hapjin | 发布于2021年03月12日 | 阅读数:2325
"properties" : {
"createTime" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss"
},
"custom" : {
"properties" : {
"groupID" : {
"type" : "keyword"
},
"projectID" : {
"type" : "keyword"
},
"serial_number" : {
"type" : "long"
},
"upload_time" : {
"type" : "keyword"
}
}
}
我新建了一个索引 face_v2,将 custom.serial_number 设置成了 keyword,然后参考 convert-the-long-datatype-field-to-string,在kibina console 里面执行如下reindex命令:(其中 custom.serial_number是 object 类型)
POST _reindex?pretty
{
"source": {
"index": "face_v1"
},
"dest": {
"index": "face_v2"
},
"script": {
"source": "ctx._source.custom.serial_number = String.valueOf(ctx._source.custom.serial_number)"
}
}
却报错了。错误如下,看错误注释貌似是 script 脚本 不支持 object field type 层级字段的 reindex ?
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx._source.custom.serial_number = String.valueOf(ctx._source.serial_number)",
" ^---- HERE"
],
"script" : "ctx._source.custom.serial_number = String.valueOf(ctx._source.serial_number)",
"lang" : "painless",
"position" : {
"offset" : 18,
"start" : 0,
"end" : 76
}
}
]
2 个回复
Joshua
赞同来自:
zmc - ES PAAS、JuiceFS
赞同来自: