# Need help to index data from MongoDB (3.2.7) into Elastic Search (5.6.3)

**URL:** https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712
**Category:** Elasticsearch
**Created:** [October 30, 2017, 5:49am UTC](https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712 "2017-10-30T05:49:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rahmathullatssr](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rahmathullatssr](https://discuss.elastic.co/u/rahmathullatssr)
#### Post date: [October 30, 2017, 5:49am UTC](https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712/1 "2017-10-30T05:49:01Z")

</div>

Hi All, I need help to index MongoDB (3.2.7) data into Elastic Search (5.6.3) In a real-time manner. After some research, I found that river plugin is deprecated. But I could read that MongoConnector can be used.

Is MongoConnector, a better option for this use-case? Or is there any other options available?

---

<div class="post-metadata">

### Author: ![rahmathullatssr](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rahmathullatssr](https://discuss.elastic.co/u/rahmathullatssr)
#### Post date: [October 31, 2017, 4:31am UTC](https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712/2 "2017-10-31T04:31:34Z")

</div>

I tried with MongoConnector with the following stack in my local environment.

1. Python 2.7.1
2. Elasticsearch 5.6.3
3. MongoDB 3.2.7
4. elastic2-doc-manager[elastic5]

Steps:

- Installed the required plugins mongo-connector and elastic2\_doc\_manager.
- Started MongoDB in 'singleNodeRepl' Mode.
- Inserted record in Mongo DB to check whether the data is getting indexed into ES. But indexing is not taking place properly.

**I could see the below error from mongo-connector.log**

2017-10-31 09:30:41,467 [ALWAYS] mongo\_connector.connector:51 - Starting mongo-connector version: 2.5.1  
2017-10-31 09:30:41,470 [ALWAYS] mongo\_connector.connector:51 - Python version: 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)]  
2017-10-31 09:30:41,474 [ALWAYS] mongo\_connector.connector:51 - Platform: Windows-7-6.1.7601-SP1  
2017-10-31 09:30:41,474 [ALWAYS] mongo\_connector.connector:51 - pymongo version: 3.5.1  
2017-10-31 09:31:11,486 [ERROR] mongo\_connector.util:106 - Fatal Exception  
Traceback (most recent call last):  
File "C:\Python27\lib\site-packages\mongo\_connector-2.5.1-py2.7.egg\mongo\_connector\[util.py](http://util.py)", line 104, in wrapped  
func(\*args, \*\*kwargs)  
File "C:\Python27\lib\site-packages\mongo\_connector-2.5.1-py2.7.egg\mongo\_connector\[connector.py](http://connector.py)", line 347, in run  
self.main\_conn.admin.command('buildInfo')['version'])  
File "C:\Python27\lib\site-packages\pymongo-3.5.1-py2.7-win-amd64.egg\pymongo\[database.py](http://database.py)", line 513, in command  
with client.\_socket\_for\_reads(read\_preference) as (sock\_info, slave\_ok):  
File "C:\Python27\lib\[contextlib.py](http://contextlib.py)", line 17, in **enter**  
return self.gen.next()  
File "C:\Python27\lib\site-packages\pymongo-3.5.1-py2.7-win-amd64.egg\pymongo\mongo\_client.py", line 904, in \_socket\_for\_reads  
with self.\_get\_socket(read\_preference) as sock\_info:  
File "C:\Python27\lib\[contextlib.py](http://contextlib.py)", line 17, in **enter**  
return self.gen.next()  
File "C:\Python27\lib\site-packages\pymongo-3.5.1-py2.7-win-amd64.egg\pymongo\mongo\_client.py", line 868, in \_get\_socket  
server = self.\_get\_topology().select\_server(selector)  
File "C:\Python27\lib\site-packages\pymongo-3.5.1-py2.7-win-amd64.egg\pymongo\[topology.py](http://topology.py)", line 214, in select\_server  
address))  
File "C:\Python27\lib\site-packages\pymongo-3.5.1-py2.7-win-amd64.egg\pymongo\[topology.py](http://topology.py)", line 189, in select\_servers  
self.\_error\_message(selector))  
ServerSelectionTimeoutError: localhost:27017: timed out

Can anybody help me on this?

---

<div class="post-metadata">

### Author: ![rahmathullatssr](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rahmathullatssr](https://discuss.elastic.co/u/rahmathullatssr)
#### Post date: [November 1, 2017, 1:44pm UTC](https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712/3 "2017-11-01T13:44:19Z")

</div>

I have made little more progress on this:

Through MongoConnector, index is getting created but the data has not been reflected.

Below are the details of my collections:  
DB: demo  
Collection Name: states  
Documents count : 4

Following are the documents:  
singleNodeRepl:PRIMARY\> db.states.find({}).pretty();  
{ "\_id" : 3, "state\_name" : "ArunachalPradesh" }  
{ "\_id" : 2, "state\_name" : "Bihar" }  
{ "\_id" : 4, "state\_name" : "Kerala" }  
{ "\_id" : 1, "state\_name" : "Andhrapradesh" }

But when I tried to access the data after index creation, I am getting the flag _ **found : false.** _

![ES_indexing](https://us1.discourse-cdn.com/elastic/original/3X/c/f/cf782ddaecdb591994a39b4284cce978122836e3.JPG)

_ **Could you please tell me why I am unable to access the data?** _

---

<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: [November 29, 2017, 1:44pm UTC](https://discuss.elastic.co/t/need-help-to-index-data-from-mongodb-3-2-7-into-elastic-search-5-6-3/105712/4 "2017-11-29T13:44:36Z")

</div>

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