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

**URL:** <https://discuss.elastic.co/t/how-to-do-custom-mapping-using-mongo-connector-with-elastic-search/31753>\
**Category:** Elasticsearch\
**Created:** [October 7, 2015, 7:58am UTC](https://discuss.elastic.co/t/how-to-do-custom-mapping-using-mongo-connector-with-elastic-search/31753 "2015-10-07T07:58:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayphate](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@jayphate](https://discuss.elastic.co/u/jayphate)\
**Post date:** [October 7, 2015, 7:58am UTC](https://discuss.elastic.co/t/how-to-do-custom-mapping-using-mongo-connector-with-elastic-search/31753/1 "2015-10-07T07:58:39Z")

</div>

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](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**

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:46pm UTC](https://discuss.elastic.co/t/how-to-do-custom-mapping-using-mongo-connector-with-elastic-search/31753/2 "2017-07-05T23:46:15Z")

</div>


