Registry / database / es-mongodb-sync

es-mongodb-sync

JSON →
library2.1.35jsnpmunverified

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.

npm install es-mongodb-sync
INSTALL
IMPORT
SIG · ES-MONGODB-SYNC
E
es-mongodb-sync
databasejavascriptv2.1.35
harness data pending
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.

MongoESConnector
const MongoESConnector = require('es-mongodb-sync');
import MongoESConnector from 'es-mongodb-sync'; // package does not support ESM
CJS-only package; no default exports. Requires 'require'.

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...'); } });
Debug
Known issues
breakingRequires MongoDB replica set – standalone instances will not work.
fix
Deploy a replica set for your MongoDB instance.
affects: >=0.0.0
deprecatedElasticsearch client version 6.x is used; not compatible with Elasticsearch 7+ (breaking changes in index/type mapping).
fix
Use package with Elasticsearch 7+ support or manually adapt the code.
affects: >=2.0.0
gotchaPackage is CJS-only and does not provide ESM exports; using import() will fail.
fix
Use require() instead of import.
affects: >=2.0.0
gotchaConfiguration file must be placed in a 'crawlerData' folder with a .json extension (not documented in all examples).
fix
Create a 'crawlerData' directory in your project root and place the config JSON file there.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: MongoESConnector.initConn is not a function
Incorrect import style (ESM vs CJS) or wrong symbol name.
fix
Use const MongoESConnector = require('es-mongodb-sync'); and call MongoESConnector.initConn(...).
Error: Oplog tailing requires a replica set
MongoDB is running as a standalone instance instead of a replica set.
fix
Convert MongoDB to a replica set by adding 'replication' config and restarting mongod.
Error: Connection refused to Elasticsearch
Elasticsearch server not running or wrong URL.
fix
Ensure Elasticsearch is running on the specified host:port and the URL is correct.
Upgrade
Version history
2.1.35latest on npm
Audit
Dependencies
mongodbrequiredNative MongoDB driver for interacting with MongoDB and tailing the oplog
elasticsearchrequiredOfficial Elasticsearch client for indexing documents
Agent activity
8 hits · last 30 days
node
6
Resources
es-mongodb-sync — npm install es-mongodb-sync · libregistry