# Es.mapping.id field duplication not allowing

**URL:** <https://discuss.elastic.co/t/es-mapping-id-field-duplication-not-allowing/85070>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [May 9, 2017, 11:12am UTC](https://discuss.elastic.co/t/es-mapping-id-field-duplication-not-allowing/85070 "2017-05-09T11:12:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [May 9, 2017, 11:12am UTC](https://discuss.elastic.co/t/es-mapping-id-field-duplication-not-allowing/85070/1 "2017-05-09T11:12:50Z")

</div>

Hi All,

I am using elasticsearch-spark-13\_2.10 artifact for storing documents in ES. I have "INITIATIVE\_CODE" field in my document which is used as \_id field using below setting,

> JavaEsSpark.saveToEs(final\_df, "rd\_innovation\_item/innovation\_item",  
> ImmutableMap.of("es.mapping.id","INITIATIVE\_CODE"));

From the input the initiative\_code has two documents,

```
US 2987621 31222335 27/07/2016 00:00:00 N 06/02/2017 01:58:54 07/02/2017 08:14:37
US 2987621 29424184 28/07/2016 00:00:00 N 06/02/2017 01:59:14 07/02/2017 08:14:37

```

After the completion of the job I found only one record. **Is there way to index these two documents in the ES?**

Please kindly share your thoughts on this.

Many Thanks,  
Ganeshbabu R

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [May 9, 2017, 2:33pm UTC](https://discuss.elastic.co/t/es-mapping-id-field-duplication-not-allowing/85070/2 "2017-05-09T14:33:22Z")

</div>

Since you have set the INITIATIVE\_CODE field as the id, any following documents that have the same value in that field will be indexed over the previous document. You will need to find a unique field to be used as your document id if you want to index both of these documents as separate documents.

---

<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:** [June 6, 2017, 2:47pm UTC](https://discuss.elastic.co/t/es-mapping-id-field-duplication-not-allowing/85070/3 "2017-06-06T14:47:00Z")

</div>

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