If Custom Routing will make document overwrited by same id

if Custom Routing will make document overwrited by same id , when there is a hash Collisions between routing? I found when routing produce same string by murmur hash, and documents with same id are overwited
for example routing=2 and routing=4, with 60 shards, and same id document will be overwited meanwhile other routing won't produce such situation.

Welcome!

You should never use the same _id for different documents whatever the _routing key is.

1 Like

thank u very much, I will make _id unique. Out of curiosity, so document will overwrites with same id when it's in same shard? I found it won't overwrite same id with different routing which not hash collision (in different shard),

Yes.

If you do:

PUT test/_doc/1
{
  "foo": "bar"
}
PUT test/_doc/1
{
  "foo": "baz"
}
GET test/_doc/1

Then you will get this document:

{
  "foo": "baz"
}

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