mongo-elastic-sync
🚀 Mongo-Elastic Sync is a Node.js library that provides synchronization between MongoDB and Elasticsearch. Seamlessly sync data changes between MongoDB collections and corresponding Elasticsearch indices.
Installation
npm install mongo-elastic-sync
Usage
const { Sync } = require("mongo-elastic-sync");
const mongoURL = "mongodb://localhost:27017";
const elasticURL = "http://localhost:9200";
const option = {
prefix: "auto-sync-",
initialSync: true,
debug: false,
};
const syncInstance = new Sync(mongoURL, elasticURL, option);
// Initial Sync (Optional)
syncInstance.initialSync();
// Start Continuous Sync
syncInstance.startSync();
Configuration
-
mongoURL
(string): MongoDB connection URL. -
elasticURL
(string): Elasticsearch connection URL. -
option
(object):-
prefix
(string, optional): Prefix for Elasticsearch indices. Default is "auto-sync-". -
initialSync
(boolean, optional): Perform an initial sync of existing MongoDB data to Elasticsearch. Default istrue
. -
debug
(boolean, optional): Enable debug mode for detailed logs. Default isfalse
.
-
Features
- 🔄 Initial Sync: Syncs existing MongoDB data to Elasticsearch upon initialization.
- 🔁 Continuous Sync: Listens for changes in MongoDB collections and updates corresponding Elasticsearch indices.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
Feel free to contribute, report issues, or request features on GitHub.