basically, I know the difference between MongoDB and the ES. In my server I have installed MongoDB instance separately will name it as (MDB1) and I installed ES instance separately will name it as (ESS). Currently, I am working on document management system, daily storing millions different kind of document information in Mongo DB. I have browsed many websites but I didn't get my answer as expected.
My question is, I want to connect ESS to MDB1, coz I using ES to search and analyze the data. Is there have any method to connect ES to existing MongoDB instance. (I am using C#.net)
There is no official connector from the Elasticsearch side. There are third-party connectors you can use. You can also do http bulk update queries to load data to ES.
Configure MongoDB on Elasticsearch
- Install MongoDB
- Configure MongoDB
mongod --config "C:\Program Files\MongoDB\Server\3.6\primary.cfg" --install --serviceName "MongoDB_Primary" --serviceDisplayName "MongoDB Primary"
mongod --config "C:\Program Files\MongoDB\Server\3.6\secondary.cfg" --install --serviceName "MongoDB_Secondary" --serviceDisplayName "MongoDB Secondary"
- Start services (Primary and Secondary instances):
- Connect to the primary database
- Install Java latest version and set java home path in variable environment
- Install Elasticsearch
- Go to Elasticsearch folder and open config folder
- Set following configuration in
http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length
- Install following files:
pip install mongo-connector[elastic5]
pip install elastic2-doc-manager[elastic5]
- Start Elasticsearch instance
- Run this command:
mongo-connector --auto-commit-interval=0 -d elastic_doc_manager -t localhost:9200
- Open http://localhost:9200/_cat/indices?v to check is mongo collections sync with Elasticsearch server
Thank you @Gehan_Fernando for sharing your recipe. I updated the format a bit as this can be useful for other members. I hope I did not change anything important (specifically, I updated a bit the mongo config).
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.