Multiple documents with same _id

Hi,
I am using single master, 2 data nodes for my cluster. (6shards, 1Replica)
I also have routing specified while indexing documents.

When i have indexed about 20Gb of documents, i can see multiple documents with same _ID :roll_eyes:

Can this happen ? As i assume that ID are unique, and even if we create many document with same ID but different content it should overwrite it and increment the _version.

Please help !!

This is either a bug in Elasticsearch or you indexed two documents with the same _id but different routing values.

The later case is true.
I have indexed two documents with same _id but different value.

But, i thought ES keeps the _id unique per index. So even if the routing value is different the index is the same.

Can you please put some light on above assumption ?

From the docs:

When indexing documents specifying a custom _routing, the uniqueness of the _id is not guaranteed across all of the shards in the index. In fact, documents with the same _id might end up on different shards if indexed with different _routing values.
It is up to the user to ensure that IDs are unique across the index.

2 Likes

Thanks mark. I would rethink of the strategy now :upside_down_face:

1 Like

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