# Duplicate \_id/\_type within the same index

**URL:** <https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954>\
**Category:** Elasticsearch\
**Created:** [November 23, 2011, 1:37pm UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954 "2011-11-23T13:37:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/max_m/32/3057_2.png) [@Max\_M](https://discuss.elastic.co/u/Max_M)\
**Post date:** [November 23, 2011, 1:37pm UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/1 "2011-11-23T13:37:16Z")

</div>

We apparently ended up with two documents sharing the same \_id/\_type pair  
within the same index. Here is a _\_search_ query's output:

GET  
"[http://192.168.72.55:19301/kqi.docubank.document.documatica\_checker.tdoc\_checker/docs/\_search?q=piieaimobdcckbghkadffhdlbmkmnpcd&pretty=1&fields=](http://192.168.72.55:19301/kqi.docubank.document.documatica_checker.tdoc_checker/docs/_search?q=piieaimobdcckbghkadffhdlbmkmnpcd&pretty=1&fields=)"  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 0.1875,  
"hits" : [ {  
"\_index" : "kqi.docubank.document.documatica\_checker.tdoc\_checker",  
"\_type" : "docs",  
"\_id" : "piieaimobdcckbghkadffhdlbmkmnpcd",  
"\_score" : 0.1875  
}, {  
"\_index" : "kqi.docubank.document.documatica\_checker.tdoc\_checker",  
"\_type" : "docs",  
"\_id" : "piieaimobdcckbghkadffhdlbmkmnpcd",  
"\_score" : 0.057534903  
} ]  
}  
}

It was my understanding that this situation should not be possibile.  
Currently, all updates affect only one of the two documents.  
We're using version 0.17.8 in a cluster of two instances. Indeces were  
initially created with version 0.11. The first copy of the document was  
indexed before migrating to 0.17.8.

Is there anything I could investigate on to undestand what might have  
happened?

Max

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 23, 2011, 3:10pm UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/2 "2011-11-23T15:10:30Z")

</div>

Are you using custom routing or parent when indexing? You can ask for  
fields=\_routing to get the routing value back as well.

On Wed, Nov 23, 2011 at 3:37 PM, Max M. [minimal.oasis@gmail.com](mailto:minimal.oasis@gmail.com) wrote:

> We apparently ended up with two documents sharing the same \_id/\_type pair  
> within the same index. Here is a _\_search_ query's output:
> 
> GET "  
> [http://192.168.72.55:19301/kqi.docubank.document.documatica\_checker.tdoc\_checker/docs/\_search?q=piieaimobdcckbghkadffhdlbmkmnpcd&pretty=1&fields=](http://192.168.72.55:19301/kqi.docubank.document.documatica_checker.tdoc_checker/docs/_search?q=piieaimobdcckbghkadffhdlbmkmnpcd&pretty=1&fields=)  
> "  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 0.1875,  
> "hits" : [ {  
> "\_index" : "kqi.docubank.document.documatica\_checker.tdoc\_checker",  
> "\_type" : "docs",  
> "\_id" : "piieaimobdcckbghkadffhdlbmkmnpcd",  
> "\_score" : 0.1875  
> }, {  
> "\_index" : "kqi.docubank.document.documatica\_checker.tdoc\_checker",  
> "\_type" : "docs",  
> "\_id" : "piieaimobdcckbghkadffhdlbmkmnpcd",  
> "\_score" : 0.057534903  
> } ]  
> }  
> }
> 
> It was my understanding that this situation should not be possibile.  
> Currently, all updates affect only one of the two documents.  
> We're using version 0.17.8 in a cluster of two instances. Indeces were  
> initially created with version 0.11. The first copy of the document was  
> indexed before migrating to 0.17.8.
> 
> Is there anything I could investigate on to undestand what might have  
> happened?
> 
> Max

---

<div class="post-metadata">

**Author:** ![Max\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/max_m/32/3057_2.png) [@Max\_M](https://discuss.elastic.co/u/Max_M)\
**Post date:** [November 24, 2011, 10:29am UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/3 "2011-11-24T10:29:14Z")

</div>

On Wednesday, November 23, 2011 4:10:30 PM UTC+1, kimchy wrote:

> Are you using custom routing or parent when indexing? You can ask for  
> fields=\_routing to get the routing value back as well.

I have never provided any _routing_\*.\* Adding fields=\_routing doesn't have  
any effect, that is: the query doesn't return any extra fields.

I also noticed another weird behavior. Our documents have a field called  
"indexing\_time". If I add it to the "fields" attribute, and repeat the same  
query a few times, that field is not always included in the response. In  
fact, it is included every other times. (It must have to do with our  
cluster comprising two servers.)

Max

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 24, 2011, 1:53pm UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/4 "2011-11-24T13:53:05Z")

</div>

Strange..., can you provide a recreation? See  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help).

On Thu, Nov 24, 2011 at 12:29 PM, Max M. [minimal.oasis@gmail.com](mailto:minimal.oasis@gmail.com) wrote:

> On Wednesday, November 23, 2011 4:10:30 PM UTC+1, kimchy wrote:
> 
> > Are you using custom routing or parent when indexing? You can ask for  
> > fields=\_routing to get the routing value back as well.
> 
> I have never provided any _routing_\*.\* Adding fields=\_routing doesn't  
> have any effect, that is: the query doesn't return any extra fields.
> 
> I also noticed another weird behavior. Our documents have a field called  
> "indexing\_time". If I add it to the "fields" attribute, and repeat the same  
> query a few times, that field is not always included in the response. In  
> fact, it is included every other times. (It must have to do with our  
> cluster comprising two servers.)
> 
> Max

---

<div class="post-metadata">

**Author:** ![Max\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/max_m/32/3057_2.png) [@Max\_M](https://discuss.elastic.co/u/Max_M)\
**Post date:** [December 1, 2011, 12:02pm UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/5 "2011-12-01T12:02:24Z")

</div>

On Thursday, November 24, 2011 2:53:05 PM UTC+1, kimchy wrote:

> Strange..., can you provide a recreation? See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help).

All attempts to recreate the problem have failed. Actually, documents are  
very often reindexed, but the problem at issue seems to only  
have occurred with that document. Replaying all operations on a fresh index  
did not yield unexpected results.  
I can, though, provide you with all the data files and the configuration.  
It's just a few KB and does not include private information.

data/config: esdata.zip ([http://goo.gl/eABZw](http://goo.gl/eABZw))  
\_index: kqi.docubank.document.documatica\_checker.tdoc\_checker  
\_type: docs  
\_id: piieaimobdcckbghkadffhdlbmkmnpcd

Max

---

<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:46am UTC](https://discuss.elastic.co/t/duplicate--id--type-within-the-same-index/5954/6 "2017-07-06T03:46:47Z")

</div>


