Okay, so I've searched everywhere on the internet for some sort of documentation on how to set up MongoDB and Elasticsearch. It appears that there is a Mongodb river plugin in the main elasticsearch github repo, but no documentation. Has anyone gotten these two lovely technologies to work together?
This is a rather old question, but I'll just post my answer in case others are wondering the same question, especially with new versions of ES coming out all the time. It took me a while to get my ES working with MongoDB too.
First, I assume you have ES and MongoDB installed. Make sure you have oplogs enabled if you're not using replica sets. Refer here on how to do it.
The river plugin has a dependency (elasticsearch-mapper-attachments), so MAKE SURE you install that first to prevent any problems later on. This wiki has the necessary commands you need to install the plugins. Take note of the alternate download link for the river plugin if you're using ES 0.20.2 and higher.
Restart ES.
Use the following command to enable the indexing:
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '
{
"type": "mongodb",
"mongodb": {
"db": "your-database-name",
"collection": "your-collection-name"
},
"index": {
"name": "mongoindex",
"type": "your-type"
}
}'
To do a search, use curl -XGET 'http://localhost:9200/mongoindex/_search?q=field:value'
I got most of my information from this website, but I felt it could be streamlined a lot more, hence my own approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With