# Trouble setting \_id path mapping

**URL:** https://discuss.elastic.co/t/trouble-setting--id-path-mapping/5935
**Category:** Elasticsearch
**Created:** [November 22, 2011, 6:38am UTC](https://discuss.elastic.co/t/trouble-setting--id-path-mapping/5935 "2011-11-22T06:38:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre/32/3014_2.png) [@Alexandre](https://discuss.elastic.co/u/Alexandre)
#### Post date: [November 22, 2011, 6:38am UTC](https://discuss.elastic.co/t/trouble-setting--id-path-mapping/5935/1 "2011-11-22T06:38:49Z")

</div>

Hi,

I'm trying to put the following mapping using the Java API :

{  
"userprofile" : {  
"\_id" : {  
"path" : "\_mid"  
},  
"properties" : {  
"\_mid" : {  
"type" : "string",  
"store" : "yes",  
"index" : "not\_analyzed"  
}  
}  
}  
}

When checking what mapping is known server side I get :

mappings: {  
userprofile: {  
properties: {  
\_mid: {  
index: not\_analyzed  
store: yes  
type: string  
}  
}  
}  
}

There is no reference to the \_id field ....

Here's how this is done in JAVA :

XContentBuilder mappingBuilder = XContentFactory.jsonBuilder()  
.startObject()  
.startObject("userprofile");

mappingBuilder.startObject("\_id");  
mappingBuilder.field("path", "\_mid");  
mappingBuilder.endObject();

mappingBuilder.startObject("properties");

mappingBuilder.startObject("\_mid");  
mappingBuilder.field("type", "string");  
mappingBuilder.field("store", Store.yes);  
mappingBuilder.field("index", Analyze.not\_analyzed);  
mappingBuilder.endObject();

getClient().admin().indices()  
.preparePutMapping().setType("userprofile")  
.setSource(mappingBuilder.string()).execute().actionGet();

getClient().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();

What am I doing wrong ?  
Why isn't the "\_id" mapping taken into account ?

Thanks for your help.

Alex

---

<div class="post-metadata">

### Author: ![Alexandre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre/32/3014_2.png) [@Alexandre](https://discuss.elastic.co/u/Alexandre)
#### Post date: [November 22, 2011, 6:59am UTC](https://discuss.elastic.co/t/trouble-setting--id-path-mapping/5935/2 "2011-11-22T06:59:18Z")

</div>

Sorry for the noise ... I was in 0.17.9 ... just upgraded to 0.18.3  
and it works perfectly now

Cheers

---

<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 6, 2017, 3:47am UTC](https://discuss.elastic.co/t/trouble-setting--id-path-mapping/5935/3 "2017-07-06T03:47:59Z")

</div>


