# Integrating mongodb with elasticSearch

**URL:** https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531
**Category:** Elasticsearch
**Created:** [May 2, 2012, 5:25am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531 "2012-05-02T05:25:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![coys](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@coys](https://discuss.elastic.co/u/coys)
#### Post date: [May 2, 2012, 5:25am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/1 "2012-05-02T05:25:14Z")

</div>

Hi, I'm trying to integrate mongodb with elasticsearch and for some  
reason I cant seem to get this working. I think there's something  
messed up with the version number combination I'm using - mongodb-  
linux 64 2.0.4 , elasticsearch 0.19.0 with the elasticsearch-river-  
mongdb jar version being 1.1 and the mongo-java-driver version being  
2.7.2. It seems to create the indices when I bring elasticsearch up  
but I cant insert a record , following the example given by  
richardwilly98, it just hangs and there's no response when i run  
db.person.save(p) on the mongotest db. Could someone please tell me  
where I'm going wrong and if you've got this working could you please  
tell me the version numbers that you're using? Thanks!

---

<div class="post-metadata">

### Author: ![lsx](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lsx](https://discuss.elastic.co/u/lsx)
#### Post date: [May 2, 2012, 5:34am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/2 "2012-05-02T05:34:30Z")

</div>

Hello.  
Please see the bad post of issue(which posted by me.)

> <https://github.com/richardwilly98/elasticsearch-river-mongodb/issues/7>
>
> Hi, I forgot something or did something wrong? there is no search result.
> I goog…le by "elasticsearch IndexMissingException" but can not solve it.
> These(1-5) are what I do:
> 1, bin/mongod --directoryperdb --dbpath=/var/data/db --logpath=/var/data/log/mongodb.log --fork
> 2, bin/elasticsearch
> 3, curl -XPUT 'http://localhost:9200/\_river/mongodb/\_meta' -d '{ 
> "type": "mongodb", 
> "mongodb": { 
> "db": "testmongo", 
> "collection": "person"
> }, 
> "index": {
> "name": "mongoindex", 
> "type": "person" 
> }
> }'
> 4, bin/mongo
> use testmongo
> db.person.save({firstName: "John", lastName: "Doe"})
> 5, curl -XGET "localhost:9200/testmongo/person/\_search?q=firstName:John&pretty=true"
> 
> And I got:
> {
> "error" : "IndexMissingException\[\[testmongo\] missing\]",
> "status" : 404
> }
> When I tail the elasticsearch.log, there are some exceptions:
> java.util.NoSuchElementException
> at java.util.LinkedList$ListItr.next(LinkedList.java:715)
> at com.mongodb.DBCursor.\_next(DBCursor.java:453)
> at com.mongodb.DBCursor.next(DBCursor.java:533)
> at org.elasticsearch.river.mongodb.MongoDBRiver$Slurper.processFullCollection(MongoDBRiver.java:378)
> at org.elasticsearch.river.mongodb.MongoDBRiver$Slurper.run(MongoDBRiver.java:353)
> at java.lang.Thread.run(Thread.java:636)
> \[2012-04-06 18:19:30,636\]\[INFO \]\[river.mongodb \] \[Rama-Tut\] \[mongodb\]\[mongodb\] No known previous slurping time for this collection
> 
> My environment:
> debian 6 64bit
> openjdk 6 64bit
> mongodb 2.0.4 Linux 64-bit
> elasticsearch 0.19.2
> and
> plugin -install elasticsearch/elasticsearch-mapper-attachments/1.2.0
> plugin -install richardwilly98/elasticsearch-river-mongodb/1.1.0
> 
> So, what's my wrong please?

You will do 2 things:

1. open the oplog of mongodb.
2. indexname is 'mongoindex', not the example's 'testmongo'.

Good Luck. 🙂

2012/5/2 coys [gautam719@gmail.com](mailto:gautam719@gmail.com):

> Hi, I'm trying to integrate mongodb with elasticsearch and for some  
> reason I cant seem to get this working. I think there's something  
> messed up with the version number combination I'm using - mongodb-  
> linux 64 2.0.4 , elasticsearch 0.19.0 with the elasticsearch-river-  
> mongdb jar version being 1.1 and the mongo-java-driver version being  
> 2.7.2. It seems to create the indices when I bring elasticsearch up  
> but I cant insert a record , following the example given by  
> richardwilly98, it just hangs and there's no response when i run  
> db.person.save(p) on the mongotest db. Could someone please tell me  
> where I'm going wrong and if you've got this working could you please  
> tell me the version numbers that you're using? Thanks!

---

<div class="post-metadata">

### Author: ![coys](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@coys](https://discuss.elastic.co/u/coys)
#### Post date: [May 2, 2012, 7:26am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/3 "2012-05-02T07:26:26Z")

</div>

> Thanks for the reply! Sorry, but I'm still stuck:( I'm now using  
> elasticsearch 0-19.2 and mongodb 2.0.4. Thanks for the querying on  
> mongoindex tip! When I query on the mongoindex using curl it tells me that  
> 5 shards were successfully created but I have 0 hits for firstname John  
> even though I inserted John Doe into mongotest/person. I'm running mongo in  
> --replSet mode and I think it's most probably a wrong file version  
> somewhere. The elasticsearch.log contains the following error  
> org.elasticsearch.common.collect.ComputationException: java.lang.NoClassDefFoundError:  
> org/elasticsearch/client/action/bulk/BulkRequestBuilder and says that  
> even though it could load the mongodb river it failed to create river  
> mongodb. Also, my plugins/river-mongodb directory has the following 2 files  
> which I manually added mongo-java-driver-2.7.2.jar and  
> elastic-river-mongodb-1.1.0-SNAPSHOT.jar. Thanks!

---

<div class="post-metadata">

### Author: ![coys](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@coys](https://discuss.elastic.co/u/coys)
#### Post date: [May 2, 2012, 11:26pm UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/4 "2012-05-02T23:26:23Z")

</div>

Just an update, I got this working now, I was using an older version of  
mongo. 2.0.4 works for me, thanks

---

<div class="post-metadata">

### Author: ![Jalpesh1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jalpesh1](https://discuss.elastic.co/u/Jalpesh1)
#### Post date: [May 31, 2017, 6:42am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/5 "2017-05-31T06:42:43Z")

</div>

Hi Coys,

Please help in integration of mongodb with elastic search.

Thanks & Regards,  
Jalpesh

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 31, 2017, 6:54am UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/6 "2017-05-31T06:54:19Z")

</div>

It's preferable to open a new question and if needed link to existing posts.

---

<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: [July 5, 2017, 9:59pm UTC](https://discuss.elastic.co/t/integrating-mongodb-with-elasticsearch/7531/7 "2017-07-05T21:59:49Z")

</div>


