# Duplicate document with same \_id and \_type

**URL:** <https://discuss.elastic.co/t/duplicate-document-with-same--id-and--type/8631>\
**Category:** Elasticsearch\
**Created:** [August 3, 2012, 4:13pm UTC](https://discuss.elastic.co/t/duplicate-document-with-same--id-and--type/8631 "2012-08-03T16:13:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [August 3, 2012, 4:23pm UTC](https://discuss.elastic.co/t/duplicate-document-with-same--id-and--type/8631/2 "2012-08-03T16:23:30Z")

</div>

On Fri, 2012-08-03 at 09:13 -0700, David Chancogne wrote:

> We are running in the same issue as in this post, unfortunately the  
> thread doesn't really have any answer ☹ :  
> [http://elasticsearch-users.115913.n3.nabble.com/duplicate-id-type-within-the-same-index-td3530682.html](http://elasticsearch-users.115913.n3.nabble.com/duplicate-id-type-within-the-same-index-td3530682.html)

> Running a search against a single index for a 'post' with a given id  
> we get 2 hits. We use \_parent and use a  
> 'userId' for the parent. The following result happens after trying  
> reassign the post to a different user and  
> reindex the post. Is \_parent somehow used in the \_uid?

A unique ID really depends on index/type/id/routing. The routing, by  
default, is derived from the ID. But if you use parent-child  
relationships, it is derived from the parent.

So if you change the parent and reindex, it may or may not end up on the  
same shard. If it is on a different shard, then the old doc will not be  
removed.

So if you're going to change the parent, you should delete the old doc  
before indexing the new doc

clint

---

_[View the full topic](https://discuss.elastic.co/t/duplicate-document-with-same--id-and--type/8631)._
