Plugin using for connecting mongodb and elasticsearch : https://github.com/richardwilly98/elasticsearch-river-mongodb
This project will help you to setup mongodb and elastic search quickly and helps you to sync mongodb collecitons with elasticsearch to perform your searches.
docker-compose up -d
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"db": "DATABASE_NAME",
"collection": "COLLECTION",
"gridfs": true,
"servers": [
{
"host": "mongodb",
"port": 27017
}
]
},
"index": {
"name": "ES_INDEX_NAME",
"type": "ES_TYPE_NAME"
}
}'
Example:
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "person",
"servers": [
{
"host": "mongodb",
"port": 27017
}
]
},
"index": {
"name": "mongoindex",
"type": "person"
}
}'
Import data from mongo console:
use testmongo
var p = {firstName: "Archit", lastName: "Dwivedi"}
db.person.save(p)
Query index:
curl -XGET 'http://localhost:9200/mongoindex/_search?q=firstName:Archit'
- Mongodb(3.0.0) Port: 27017
- Elastic Search(1.7.3) Port: 9200: Log in
MongoDB:
# Check logs
docker-compose logs -f mongodb
# Log in Mongodb
docker-compose exec mongodb bash
Elastic Search:
# Check Logs
docker-compose logs -f elasticsearch
# Log in ElasticSearch
docker-compose exec elasticsearch bash