Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up MongoDB river for Elasticsearch

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?

like image 507
Eric Simons Avatar asked Feb 04 '12 11:02

Eric Simons


1 Answers

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.

  1. 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.

  2. 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.

  3. Restart ES.

  4. 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"
        }
    }'
    
  5. 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.

like image 186
Wei Hao Avatar answered Sep 28 '22 08:09

Wei Hao