使用Canal同步mysql数据到Elasticsearch时,坐标不符合规范报错:
failed to parse field [location] of type [geo_point]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=illegal latitude value
原因:
使用Canal同步数据含有坐标时,需要确保坐标存在、格式正确。
Canal同步mysql经纬度字段数据至es的geo_point类型数据,同步语句先处理一下。
解决:
1、官方解决方案:
concat(IFNULL(ws.lat,0),',',IFNULL(ws.lng,0)) as location
实际上这样依然报错,因为数据库部分坐标数据格式不正确,语句需要修改,还需要ES忽略错误的格式。
2、忽略不正确的格式:
使用 index.mapping.ignore_malformed 全局忽略异常
"index.mapping.ignore_malformed": true // 允许在所有映射类型中全局忽略格式错误的内容
但是即使ignore_malformed已配置,canal依然报错。
3、最终解决方案:
Canal同步语句设为:
concat(IF(ws.lat,ROUND(ws.lat,6),&#