elasticsearch-river-mongodb
elasticsearch-river-mongodb copied to clipboard
elasticsearch-river-mongodb
I'm building an ASP.NET MVC site with MongoDB[GridFs to store files] where I want to implement search using Elastic Search. I saved some file in Mongo Db's gridFS and then indexed the collection using river, searching in files using elastic search. I performed following :
GridFS Mongo document (with large binary content) requires transformation before being stored in ElasticSearch. It requires mapper-attachment plugin installed in ElasticSearch. I have below plugins installed in ElasticSearch:
I am using MongoDB River plugin for integration of ES and MongoDB ,which is responsible for the transfer of data between the two db.
- Mongo DB Side:
mongod --port 27017 --replSet rs0
mongod --port 27018 –replSet rs1
mongo localhost:27017
rs.initiate()
rs.add("hostname:27018")
mongofiles.exe --host localhost:27017 --db PictureApplication --collection fs put C:\test.pdf mongofiles.exe --host localhost:27017 --db PictureApplication --collection fs put C:\test1.txt mongofiles.exe --host localhost:27017 --db PictureApplication --collection fs put C:\test.doc
- Elastic Search Side (Installed Plugins : as shown above in screenshot) àUsing Sense (a JSON Aware Interface to Elasticsearch) created index as below: PUT _river/mongogridfs/_meta -d' { "type": "mongodb", "mongodb": { "db": "PictureApplication", "collection": "fs", "gridfs": true }, "index": { "name": "picindex", "type": "files" } }
->Also tried Elastic Search Head given following request from "Any request" tab
URL : http://localhost:9200/_river/mongodb/
_meta/PUT
{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "fs.files",
"gridfs": true,
"contentType": "",
"content": "base64 /path/filename | perl -pe 's/\n/\\n/g'"
},
"index": {
"name": "testmongo",
"type": "files",
"content_type": "application/pdf"
}
}
Now i am trying to access following URL :
http://localhost:9200/_river/files/54cb54d718db8c1e9c4639bd?pretty=true I got following response (Which i believe not expected) :
when i try in sensa:
Here its showing me no hits but the file present in db.
Also find below screenshot of Indeces in head:
Please let me know if I am doing anything wrong or missed something.
