mongodb-elasticsearch-sync
Syncronize MongoDB and Elasticseach database. Copy and convert all data from a MongoDB database and index it in Elasticsearch.
Usage
Run this command by giving a MongoDB URI and Elasticsearch URI (no need to install first thanks to npx
):
npx mongodb-elasticsearch-sync \
--mongodbUri=mongodb://localhost:27017/source \
--elasticsearchUri=mongodb://localhost:27017/anonymized
Options
Use --singularizeName
to transform users
collection in MongoDB into user
in Elasticsearch.
npx mongodb-elasticsearch-sync \
--mongodbUri=mongodb://localhost:27017/source \
--elasticsearchUri=mongodb://localhost:27017/anonymized
--singularizeName
Why
I recently created a tool 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.