mongodb-elasticsearch-sync

Sync mongoDB and elasticseach

Usage no npm install needed!

<script type="module">
  import mongodbElasticsearchSync from 'https://cdn.skypack.dev/mongodb-elasticsearch-sync';
</script>

README

mongodb-elasticsearch-sync

Syncronize MongoDB and Elasticseach database. Copy and convert all data from a MongoDB database and index it in Elasticsearch.

oclif Version License

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

☝️ Be careful, since Elasticsearch indexed will be reset.

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.