# Upgrade from 2.1.1 to 2.2.0: field \_id is defined twice elasticsearch

**URL:** <https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845>\
**Category:** Elasticsearch\
**Created:** [February 3, 2016, 9:08am UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845 "2016-02-03T09:08:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edeak](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@edeak](https://discuss.elastic.co/u/edeak)\
**Post date:** [February 3, 2016, 9:08am UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/1 "2016-02-03T09:08:10Z")

</div>

Hi guys,

I've just upgraded my elasticsearch cluster with full cluster restart.  
I have two defined indices.  
Now when I started my data nodes, I get an exception on each index: `Field [_id] is defined twice in [myType]`.  
How can I fix this?

---

<div class="post-metadata">

**Author:** ![jillesvangurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jillesvangurp/32/3863_2.png) [@jillesvangurp](https://discuss.elastic.co/u/jillesvangurp)\
**Post date:** [February 11, 2016, 11:48am UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/2 "2016-02-11T11:48:38Z")

</div>

I'm seeing this as well

This bulk indexing request now fails in 2.2.0

```auto
{"index":{"_index":"test_5zogjdzthm_v2","_type":"test","_id":"obj_5"}}
{"id":"obj_5","created_at":"2016-02-11T11:32:43.184Z","updated_at":"2016-02-11T11:32:43.184Z","_type":"test"}

```

The fix is obvious: don't repeat the \_type in the object.

---

<div class="post-metadata">

**Author:** ![joshbedo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshbedo/32/7771_2.png) [@joshbedo](https://discuss.elastic.co/u/joshbedo)\
**Post date:** [February 12, 2016, 10:55pm UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/3 "2016-02-12T22:55:36Z")

</div>

Yeah i'm having the same error with mongoosastic.. its complaining about duplicated "\_id". [https://github.com/mongoosastic/mongoosastic/issues/165](https://github.com/mongoosastic/mongoosastic/issues/165)

---

<div class="post-metadata">

**Author:** ![michelem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michelem/32/8213_2.png) [@michelem](https://discuss.elastic.co/u/michelem)\
**Post date:** [March 2, 2016, 2:26pm UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/4 "2016-03-02T14:26:36Z")

</div>

I have same issue I'm receiving a lot of logs like this:

```
[2016-03-02 15:23:56,427][WARN][cluster.action.shard] [esearch] [streetlib-dev3][2] received shard failed for [streetlib-dev3][2], node[6Hrw6K6mRKWbnl6L9YC8sw], [P], v[847], s[INITIALIZING], a[id=TK2N4o7yT-GCqkL_N_Rnew], unassigned_info[[reason=ALLOCATION_FAILED], at[2016-03-02T14:23:51.370Z], details[failed to update mappings, failure IllegalArgumentException[Field [_id] is defined twice in [catalog]]]], indexUUID [7EfzsOa_TwSuUBycDPyiqA], message [failed to update mappings], failure [IllegalArgumentException[Field [_id] is defined twice in [catalog]]]
java.lang.IllegalArgumentException: Field [_id] is defined twice in [catalog]
	at org.elasticsearch.index.mapper.MapperService.checkFieldUniqueness(MapperService.java:377)
	at org.elasticsearch.index.mapper.MapperService.checkMappersCompatibility(MapperService.java:385)
	at org.elasticsearch.index.mapper.MapperService.checkMappersCompatibility(MapperService.java:411)
	at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:314)
	at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:272)
	at org.elasticsearch.indices.cluster.IndicesClusterStateService.processMapping(IndicesClusterStateService.java:388)
	at org.elasticsearch.indices.cluster.IndicesClusterStateService.applyMappings(IndicesClusterStateService.java:348)
	at org.elasticsearch.indices.cluster.IndicesClusterStateService.clusterChanged(IndicesClusterStateService.java:164)
	at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:600)
	at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:762)
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

```

I fixed it as I can use the search now, but how can I fix the indexes so I don't receive this warning anymore?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [March 2, 2016, 6:30pm UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/5 "2016-03-02T18:30:58Z")

</div>

This is new validation that we added in 2.2 to assert that mappings could not define the same field twice, as it could result in ambiguity at search time: elasticsearch would not know which field to pick. For new indices (created on or after 2.2) then elasticsearch will make sure to reject mapping updates that try to introduce such broken mappings. However if you are upgrading from an older release and have an old index that has this problem, the only way to fix is to reindex.

---

<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:11pm UTC](https://discuss.elastic.co/t/upgrade-from-2-1-1-to-2-2-0-field--id-is-defined-twice-elasticsearch/40845/6 "2017-07-05T23:11:55Z")

</div>


