zhr85210078 / node-mongodb-es-connector

nodejs mongodb elasticsearch synchrodata(mongodb和es同步数据)
https://zhr85210078.github.io/node-mongodb-es-connector/#/
MIT License
77 stars 17 forks source link

[feature request] 能否在mongodb 同步 elasticsearch到之前加一个回调,自定义增加一些mongdb集合中没有的属性. #10

Closed treemore closed 6 years ago

treemore commented 6 years ago

如mongo db数据

{
a:1,
b:2
}

现在同步到es 中只能是

{
a:1,
b:2
}

增加一个promise 函数. 如

async function  transformat(mongoResult){
return {
...mongoResult,
type:"99"
}
}

这样同步到elastic search中数据就变成了

{
a:1,
b:2,
type:99
}

而不用在mongo db中增加type:99 属性. 这个需求在通一个mongo 表同步到多个elastic 的type中中很有用.

zhr85210078 commented 6 years ago

这个需求在我较早的版本中实现过,后来我自己的应用场景变成了使用elasticsearch的pipeline来完成 yxvpm 3pdy f7da85x257ln 我可以在下一个版本中把你想要加的这个配置冗进去,保证各种应用场景,希望大家多提意见,工具更加完善

zhr85210078 commented 6 years ago

在v2.1.9版本中我增加了一个配置文件节点:

"m_extendfilds": { "bA": "this is a extend fild bA", "bB": "this is a extend fild bB" } 具体你可以参考我提供的例子 应该可以满足你的应用场景,希望可以帮助到你