https://github.com/rap2hpoutre/mongodb-elasticsearch-sync
Copy data from MongoDB to Elasticsearch with a NodeJS CLI
https://github.com/rap2hpoutre/mongodb-elasticsearch-sync
cli database elasticsearch hacktoberfest javascript mongodb nodejs synchronization
Last synced: about 1 year ago
JSON representation
Copy data from MongoDB to Elasticsearch with a NodeJS CLI
- Host: GitHub
- URL: https://github.com/rap2hpoutre/mongodb-elasticsearch-sync
- Owner: rap2hpoutre
- Created: 2021-07-08T21:57:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-09T14:41:21.000Z (almost 5 years ago)
- Last Synced: 2025-03-24T23:51:23.459Z (over 1 year ago)
- Topics: cli, database, elasticsearch, hacktoberfest, javascript, mongodb, nodejs, synchronization
- Language: TypeScript
- Homepage:
- Size: 48.8 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
mongodb-elasticsearch-sync
==========================
Syncronize MongoDB and Elasticseach database. Copy and convert all data from a MongoDB database
and index it in Elasticsearch.
[](https://oclif.io)
[](https://npmjs.org/package/mongodb-elasticsearch-sync)
[](https://github.com/rap2hpoutre/mongodb-elasticsearch-sync/blob/main/package.json)
## Usage
Run this command by giving a MongoDB URI and Elasticsearch URI (no need to install first thanks to `npx`):
```bash
npx mongodb-elasticsearch-sync \
--mongodbUri=mongodb://localhost:27017/source \
--elasticsearchUri=mongodb://localhost:27017/anonymized
```
☝️ Be careful, since Elasticsearch indexed will be reset.
### Options
Use `--singularizeName` to transform `users` collection in MongoDB into `user` in Elasticsearch.
```bash
npx mongodb-elasticsearch-sync \
--mongodbUri=mongodb://localhost:27017/source \
--elasticsearchUri=mongodb://localhost:27017/anonymized
--singularizeName
```
## Why
I recently created a [tool](https://github.com/rap2hpoutre/mongodb-anonymizer#mongodb-anonymizer)
to anonymize MongoDB database (from a source db to a target db) to help me build a staging
environment for a project. Since I use MongoDB with Elasticsearch for this project, I needed a
one-line command to create the Elascticsearch indices after this process.