How to load data from MongoDb to ElasticSearch
Learn how to use Airbyte to synchronize your MongoDb data into ElasticSearch within minutes.


Building your pipeline or Using Airbyte
Airbyte is the only open source solution empowering data teams to meet all their growing custom business demands in the new AI era.
- Inconsistent and inaccurate data
- Laborious and expensive
- Brittle and inflexible
- Reliable and accurate
- Extensible and scalable for all your needs
- Deployed and governed your way
Start syncing with Airbyte in 3 easy steps within 10 minutes



Take a virtual tour
Demo video of Airbyte Cloud
Demo video of AI Connector Builder
Setup Complexities simplified!
Simple & Easy to use Interface
Airbyte is built to get out of your way. Our clean, modern interface walks you through setup, so you can go from zero to sync in minutes—without deep technical expertise.
Guided Tour: Assisting you in building connections
Whether you’re setting up your first connection or managing complex syncs, Airbyte’s UI and documentation help you move with confidence. No guesswork. Just clarity.
Airbyte AI Assistant that will act as your sidekick in building your data pipelines in Minutes
Airbyte’s built-in assistant helps you choose sources, set destinations, and configure syncs quickly. It’s like having a data engineer on call—without the overhead.
What sets Airbyte Apart
Modern GenAI Workflows
Move Large Volumes, Fast
An Extensible Open-Source Standard
Full Control & Security
Fully Featured & Integrated
Enterprise Support with SLAs
What our users say

Raman Singh
Predictable, straightforward pricing model that simplified budgeting and significantly reduced overall spend

Chase Zieman

“Airbyte helped us accelerate our progress by years, compared to our competitors. We don’t need to worry about connectors and focus on creating value for our users instead of building infrastructure. That’s priceless. The time and energy saved allows us to disrupt and grow faster.”

Rupak Patel
"With Airbyte, we could just push a few buttons, allow API access, and bring all the data into Google BigQuery. By blending all the different marketing data sources, we can gain valuable insights."
How to Sync to Manually
First, you need to export the data from MongoDB. You can use the mongoexport command-line tool provided by MongoDB to export your data in JSON format.
mongoexport --db your_db_name --collection your_collection_name --out data.json
Replace your_db_name with the name of your MongoDB database, and your_collection_name with the name of the collection you want to export. The exported data will be saved in the data.json file.
Before you can import the data into Elasticsearch, you need to have Elasticsearch installed and running. Follow the official Elasticsearch installation guide for your operating system: https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
Once installed, start Elasticsearch. By default, it runs on http://localhost:9200.
You need to create an index in Elasticsearch where you will import the MongoDB data. You can do this using a tool like cURL or Kibana's Dev Tools.
curl -X PUT "localhost:9200/your_index_name" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"field1": { "type": "text" },
"field2": { "type": "date" },
// Define other fields as necessary
}
}
}'
Replace your_index_name with the desired name for your Elasticsearch index, and define the appropriate mappings for your data.
Depending on your data structure, you may need to transform the exported JSON data to match the mappings you've set up in Elasticsearch. You can write a script in a language like Python to transform the data.
For example, if you need to convert a date field from a string to a date format that Elasticsearch understands, you would write a script that reads the data.json file, parses the data, and transforms the date fields.
Once the data is in the correct format, you can import it into Elasticsearch using the Bulk API. This can be done using a tool like cURL or by writing a script.
Here's an example of how to use cURL to post data to the Elasticsearch Bulk API:
curl -X POST "localhost:9200/your_index_name/_bulk" -H 'Content-Type: application/x-ndjson' --data-binary @data.ndjson
The data.ndjson file should contain the transformed data in newline-delimited JSON (NDJSON) format, which is required by the Bulk API. Each line in the NDJSON file should contain a JSON object that represents a single document to be indexed.
The NDJSON format for the Bulk API looks like this:
{ "index" : { "_index" : "your_index_name", "_id" : "1" } }
{ "field1": "value1", "field2": "value2" }
{ "index" : { "_index" : "your_index_name", "_id" : "2" } }
{ "field1": "value3", "field2": "value4" }
...
After importing the data, verify that it has been correctly indexed in Elasticsearch by performing a search query:
curl -X GET "localhost:9200/your_index_name/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
}
}'
This will return a list of documents indexed in the your_index_name index.
If you encounter any issues during the import process, check the Elasticsearch logs for error messages. Common issues include data format mismatches, incorrect field mappings, or network connectivity problems.
Additional considerations:
- Ensure that your MongoDB and Elasticsearch instances are properly secured, especially if they are exposed to the internet.
- If you have a large dataset, consider using parallel processing or splitting the data into chunks to speed up the export and import process.
- Always back up your data before performing operations like this to prevent data loss.