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.
Building in-house pipelines
- Inconsistent and inaccurate data
- Laborious and expensive
- Brittle and inflexible
After Airbyte
- 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
Streamline AI workflows with Airbyte: load unstructured data into vector stores like Pinecone, Weaviate, and Milvus. Supports RAG transformations with LangChain chunking and embeddings from OpenAI, Cohere, etc., all in one operation.
Move Large Volumes, Fast
Quickly get up and running with a 5-minute setup that enables both incremental and full refreshes for databases of any size, seamlessly scaling to handle large data volumes. Our optimized architecture overcomes performance bottlenecks, ensuring efficient data synchronization even as your datasets grow from gigabytes to petabytes.
An Extensible Open-Source Standard
More than 1,000 developers contribute to Airbyte’s connectors, different interfaces (UI, API, Terraform Provider, Python Library), and integrations with the rest of the stack. Airbyte’s AI Connector Builder lets you edit or add new connectors in minutes.
Full Control & Security
Airbyte secures your data with cloud-hosted, self-hosted or hybrid deployment options. Single Sign-On (SSO) and Role-Based Access Control (RBAC) ensure only authorized users have access with the right permissions. Airbyte acts as a HIPAA conduit and supports compliance with CCPA, GDPR, and SOC2.
Fully Featured & Integrated
Airbyte automates schema evolution for seamless data flow, and utilizes efficient Change Data Capture (CDC) for real-time updates. Select only the columns you need, and leverage our dbt integration for powerful data transformations.
Enterprise Support with SLAs
Airbyte Self-Managed Enterprise comes with dedicated support and guaranteed service level agreements (SLAs), ensuring that your data movement infrastructure remains reliable and performant, and expert assistance is available when needed.
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
Step 1: Export Data from MongoDB
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.
Step 2: Install and Run Elasticsearch
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.
Step 3: Create an Index in Elasticsearch
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.
Step 4: Transform Data (If Necessary)
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.
Step 5: Import Data into Elasticsearch
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" }
...
Step 6: Verify the Data Import
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.
Step 7: Troubleshooting
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.