# Field \[\_id\] is defined twice in \[type\]

**URL:** <https://discuss.elastic.co/t/field--id-is-defined-twice-in-type/73565>\
**Category:** Elasticsearch\
**Created:** [February 1, 2017, 6:16pm UTC](https://discuss.elastic.co/t/field--id-is-defined-twice-in-type/73565 "2017-02-01T18:16:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![herix](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@herix](https://discuss.elastic.co/u/herix)\
**Post date:** [February 1, 2017, 6:16pm UTC](https://discuss.elastic.co/t/field--id-is-defined-twice-in-type/73565/1 "2017-02-01T18:16:22Z")

</div>

Hello,

I'm trying to give my \_id a default data type so I'm defining a custom mapping for it.

PUT /test\_index  
{  
"mappings": {  
"product": {  
"properties": {  
"\_id": {  
"index": false,  
"type": "keyword"  
}  
}  
}  
}  
}

Error:

{  
"error": {  
"root\_cause": [  
{  
"type": "mapper\_parsing\_exception",  
"reason": "Failed to parse mapping [product]: Field [\_id] is defined twice in [product]"  
}  
],  
"type": "mapper\_parsing\_exception",  
"reason": "Failed to parse mapping [product]: Field [\_id] is defined twice in [product]",  
"caused\_by": {  
"type": "illegal\_argument\_exception",  
"reason": "Field [\_id] is defined twice in [product]"  
}  
},  
"status": 400  
}

The type "product" exists in other indices, however. Is this the expected behavior? Do I need to fix my mapping on every index that has the same "product" type?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [February 2, 2017, 4:38am UTC](https://discuss.elastic.co/t/field--id-is-defined-twice-in-type/73565/2 "2017-02-02T04:38:10Z")

</div>

You can't define a field called `_id` on a type; [`_id`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html) is the name of a metadata field used for the id of the document.

I'd suggest naming it something else, like `product_id` or just `id`.

---

<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:** [March 2, 2017, 4:38am UTC](https://discuss.elastic.co/t/field--id-is-defined-twice-in-type/73565/3 "2017-03-02T04:38:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
