Node.js package that synchronizes MongoDB collections with Elasticsearch indices by tailing the MongoDB oplog. Supports one-to-one and one-to-many mappings, attachment sync, and filtering. Compatible with Elasticsearch 6.x and MongoDB 3.6+. Currently at version 2.1.35, with no recent updates. Requires a MongoDB replica set. Key differentiator: real-time sync via oplog tailing without additional middleware.
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CJS-only package; no default exports. Requires 'require'.
const MongoESConnector = require('es-mongodb-sync');
Initializes the MongoDB to Elasticsearch sync connector with Oplog tailing configuration.
const MongoESConnector = require('es-mongodb-sync');
const config = {
mongodb: {
m_database: 'myTest',
m_collectionname: 'books',
m_filterfilds: { version: '2.0' },
m_returnfilds: { bName: 1, bPrice: 1 },
m_extendfilds: { bA: 'extend A' },
m_connection: {
m_servers: ['localhost:27017'],
m_authentication: {
username: 'UserAdmin',
password: 'pass1234',
authsource: 'admin',
replicaset: 'my_replica',
ssl: false
}
},
m_documentsinbatch: 5000,
m_delaytime: 1000
},
elasticsearch: {
e_index: 'mybooks',
e_type: 'books',
e_connection: {
e_server: 'http://localhost:9200',
e_httpauth: {
username: 'EsAdmin',
password: 'pass1234'
}
},
e_pipeline: 'mypipeline',
e_iscontainattachment: false
}
};
MongoESConnector.initConn(config, function(err) {
if (err) {
console.error('Init error:', err);
} else {
console.log('Syncing started...');
}
});
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.