What is expected behaviour when indexing with same ID, different parent

Hi there,

I would like to ask what is expected behaviour when I will index with the same ID but different parent multiple times?

For example:

PUT /tests/a/50?parent=25
  "item": "C"

PUT /tests/a/50?parent=26
  "item": "D"

PUT /tests/a/50?parent=50
  "item": "E",
  "item2": "F",

What should be the result? 1 document with 3 versions or 3 different documents?

Interesting... I wonder if we ever considered that. Actually a child can have only one parent.
In theory you should have at the end only one document.

But if you have more than one shard, I suspect you can end up with more than one... What are you seeing?

As the parent id determines which shard the document is routed to, I suspect you would end up with an undefined number of child documents. If they all get routed to different shards you would have 3, but any documents that end up in the same shard should cause an update which would replace the previous version. If they all ended up on the same shard you should probably have just one child document.

I am seeing exactly what @Christian_Dahlqvist wrote - an undefined number of child documents - sometimes there are 3 sometimes only one.

Is it a bug and should be reported on github or it is not? At least I would appreciate some warning or mentioning in docs :slight_smile:

I'd propose a documentation contribution saying that it's super important to keep the same parent id any time.

This is not something we can fix IMO.

1 Like

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