开发者社区> 问答> 正文

canal adapter的esMapping pk问题

配置如下:

dataSourceKey: defaultDS destination: dbastatinfo groupId: g1 esMapping: _index: dbastatinfo _type: _doc pk: _id sql: "select a.iGId as _id, a.inip from processlistinfo a" commitBatch: 1000

这么写,能拿到解析的数据,但是不能写到ES中。

日志如下:

2019-04-19 14:46:41.961 [pool-4-thread-1] DEBUG c.a.otter.canal.client.adapter.es.service.ESSyncService - DML: {"data":[{"id":7571826,"iGId":"1111","inip":"xxxx","port":1111,"iRole":"slave","proid":5073476,"USER":"xxxx","HOST":"xxxx","DB":"xxxx","COMMAND":"Sleep","TIME":39,"STATE":"","INFO":"None","addTime":1555524615000,"addDate":1555516800000,"version":"20190418021001","note":""}],"database":"xxxx","destination":"dbastatinfo","es":1555524615000,"groupId":null,"isDdl":false,"old":null,"pkNames":["id"],"sql":"","table":"processlistinfo","ts":1555656400212,"type":"INSERT"}

如果使用:

dataSourceKey: defaultDS destination: dbastatinfo groupId: g1 esMapping: _index: dbastatinfo _type: _doc _id: _id sql: "select a.iGId as _id, a.inip from processlistinfo a" commitBatch: 1000

则可正常写入。

求问:ES自动分配_id时,pk的配置应该怎么写?

原提问者GitHub用户Mysia

展开
收起
古拉古拉 2023-05-08 12:19:33 86 0
1 条回答
写回答
取消 提交回答
  • 有_id就不需要pk

    原回答者GitHub用户rewerma

    2023-05-09 17:35:02
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载