# Migrating data(which already exists) from Mongodb to elasticsearch

**URL:** <https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168>\
**Category:** Elasticsearch\
**Created:** [November 17, 2018, 9:48am UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168 "2018-11-17T09:48:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Krishna](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sai\_Krishna](https://discuss.elastic.co/u/Sai_Krishna)\
**Post date:** [November 17, 2018, 9:48am UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168/1 "2018-11-17T09:48:21Z")

</div>

Hi Everyone,  
I am new to elasticsearch. I tried a lot but I am unable to find the way to send **already present data(collections) of mongodb to elasticsearch**. I successfully established the connection between mongodb and elasticsearch using "mongoosastic" plugin. Able to send the newly entered data to elastic from mongodb. **But my question is "how could I send the collections which are already present in mongodb"??**

I am using "Nodejs" for development.

---

<div class="post-metadata">

**Author:** ![Sai\_Krishna](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sai\_Krishna](https://discuss.elastic.co/u/Sai_Krishna)\
**Post date:** [November 20, 2018, 7:06am UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168/2 "2018-11-20T07:06:36Z")

</div>

I came to know that .synchronize() method of mongoosastic would index all the data already existing.  
But it is taking time when there is huge collection which contains 1-2 million documents.  
Can any one suggest what would be the alternative to do this?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [November 20, 2018, 10:15am UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168/3 "2018-11-20T10:15:25Z")

</div>

Hello,  
Even i am facing the same problem and i am following this way,  
Using logstash, we will be querying the data into elasticsearch.  
So write a query to split the data like  
1st query(to load from 1 - 1000000 rows) data from database  
2nd query(to load from 1000000 - 2000000 rows) data from database  
...  
...  
...  
which will helps to load complete data without any disturbances.

hope this helps you.

---

<div class="post-metadata">

**Author:** ![Sai\_Krishna](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sai\_Krishna](https://discuss.elastic.co/u/Sai_Krishna)\
**Post date:** [November 20, 2018, 12:20pm UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168/4 "2018-11-20T12:20:42Z")

</div>

Thank you very much.  
But we are not using **logstash** in our project .  
So can you suggest another way through which i can send data from mongodb to elasticsearch.  
Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 18, 2018, 12:20pm UTC](https://discuss.elastic.co/t/migrating-data-which-already-exists-from-mongodb-to-elasticsearch/157168/5 "2018-12-18T12:20:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
