使用Datax同步数据写入elasticsearch报错:Mapper for [createdTime] conflicts with existing mapping
使用datax把数据同步到elasticsearch的时候,报错了,报错信息如下:
在elasticsearch中,我们创建的mapping的时候指定了createTime为date类型及指定了format格式:
datax的writer配置如下:
尝试过在datax的writer这里添加上format,结果不管用,请问怎么办?
ERROR ElasticSearchClient - PutMapping got ResponseCode: 400, ErrorMessage: {"root_cause":[{"type":"illegal_argument_exception","reason":"Mapper for [createdTime] conflicts with existing mapping:\n[mapper [createdTime] has different [format] values]"}],"type":"illegal_argument_exception","reason":"Mapper for [createdTime] conflicts with existing mapping:\n[mapper [createdTime] has different [format] values]"}
在elasticsearch中,我们创建的mapping的时候指定了createTime为date类型及指定了format格式:
"createTime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
datax的writer配置如下:
{
"name": "createdTime",
"type": "date"
}
尝试过在datax的writer这里添加上format,结果不管用,请问怎么办?
发布于:2年前 (2023-04-18) IP属地:四川省
1 个回答
在datax的writer插件里面,会先获取elasticsearch中index的配置,但是由于elasticsearch writer不会去读取datax中的format配置,因此获取到的两个index mapping是不一致的,如下图:

由于在这里的两个mapping不一致,比对的时候就会出现两个,所以就会直接失败,报错:
所以我们在elasticsearch中,不要指定format格式即可。

由于在这里的两个mapping不一致,比对的时候就会出现两个,所以就会直接失败,报错:
Mapper for [createdTime] conflicts with existing mapping:\n[mapper [createdTime] has different [format] values
所以我们在elasticsearch中,不要指定format格式即可。
发布于:2年前 (2023-04-18) IP属地:四川省
我来回答
您需要 登录 后回答此问题!