How to do custom mapping using mongo connector with Elastic-search


(Jay) #1

I wanna connect mongodb and elasticsearch. I used mongo connector to connect them. I followed instruction from below link to setup==>

http://vi3k6i5.blogspot.in/2014/12/using-elastic-search-with-mongodb.html

I am able to connect mongodb and elastic search by mongo connector. But by default mongo connector created indices in elasticsearch for all databases of mongodb.

I want to create only one index for my one database and I want to insert only selected field of documents. for example: in mongo shell==>

use hotels
db.restaurants.insert(
{
  "address" : {
 "street" : "2 Avenue",
 "zipcode" : "10075",
 "building" : "1480",
 "coord" : [ -73.9557413, 40.7720266 ],
},
"borough" : "Manhattan",
"cuisine" : "Italian",
"grades" : [
 {
    "date" : ISODate("2014-10-01T00:00:00Z"),
    "grade" : "A",
    "score" : 11
 },
 {
    "date" : ISODate("2014-01-16T00:00:00Z"),
    "grade" : "B",
    "score" : 17
 }
],
 "name" : "Vella",
 "restaurant_id" : "41704620"
 }
)

This will create database hotels and collection restaurants. Now I want to create index and I want to put only address field in elasticsearch for that index.

Below are the steps what I tried but thats not working : First I start mongo connector like below :

Imomadmins-MacBook-Pro:~ jayant$ mongo-connector -m localhost:27017 -t       localhost:9200 -d elastic_doc_manager --oplog-ts oplogstatus.txt

Logging to mongo-connector.log.

Then from new shell tab, I made command like :

curl -XPUT 'http://localhost:9200/hotels.restaurants/'

Then I made next command :

curl -XPUT "http://localhost:9200/hotels.restaurants/string/_mapping" -    d'{
"string": {
    "properties" : {
    "address" : {"type" : "string"}
     }
 }
}'

But only index is created in elasticsearch named as hotels.restaurants. I can't see any document for index hotels.restaurants.

Please suggest me how to add document for hotels.restaurants


(system) #2