diff --git a/Sync-ES.md b/Sync-ES.md index 2552981..68248cc 100644 --- a/Sync-ES.md +++ b/Sync-ES.md @@ -208,6 +208,74 @@ left join (select user_id, group_concat(label order by id desc separator ';') as objFields: labels: array:; ``` +- 父子文档索引 + +es/customer.yml +``` +...... +esMapping: + _index: customer + _type: _doc + _id: id + relations: + customer_order: + name: customer + sql: "select t.id, t.name, t.email from customer t" +``` +es/order.yml +``` +esMapping: + _index: customer + _type: _doc + _id: _id + relations: + customer_order: + name: order + parent: customer_id + sql: "select concat('oid_', t.id) as _id, + t.customer_id, + t.id as order_id, + t.serial_code as order_serial, + t.c_time as order_time + from biz_order t" + skips: + - customer_id +``` +mapping示例: +``` +{ + "mappings":{ + "_doc":{ + "properties":{ + "id": { + "type": "long" + }, + "name": { + "type": "text" + }, + "email": { + "type": "text" + }, + "order_id": { + "type": "long" + }, + "order_serial": { + "type": "text" + }, + "order_time": { + "type": "date" + }, + "customer_order":{ + "type":"join", + "relations":{ + "customer":"order" + } + } + } + } + } +} +``` ### 3 启动ES数据同步 #### 启动canal-adapter启动器