# Unique IDs on joinType data structures

**URL:** <https://discuss.elastic.co/t/unique-ids-on-jointype-data-structures/180959>\
**Category:** Elasticsearch\
**Created:** [May 14, 2019, 8:55am UTC](https://discuss.elastic.co/t/unique-ids-on-jointype-data-structures/180959 "2019-05-14T08:55:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HJK181](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HJK181](https://discuss.elastic.co/u/HJK181)\
**Post date:** [May 14, 2019, 8:55am UTC](https://discuss.elastic.co/t/unique-ids-on-jointype-data-structures/180959/1 "2019-05-14T08:55:59Z")

</div>

As suggests in this issue: [Possible to index duplicate documents with same id and routing id. · Issue #31976 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/31976#issuecomment-491835349)

I want to start a discussion about the problem described in [Possible to index duplicate documents with same id and routing id. · Issue #31976 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/31976#issuecomment-491799670)

Given a parent-child relation over the joinType data structure:  
If two "parent" documents get placed on different shards, one can add the same "child" to both of the documents. But if the calculated hash results in those two documents to be places on the same shard, it wouldn't be possible. This is not a consistent behavior.

So the question is, how can I have a constraint on unique IDs without issuing a search request which checks if a document already exists before adding a new child document?

Background information: We have a frontend where customers can add child documents to existing parent documents, but the same child document is only allowed to be added once thus we can't make sure the document with the same ID always get's the same routing key as suggested in the github issue answer:

> You need to ensure that if you use routing values two documents with the same id cannot have different routing keys

---

<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:** [June 11, 2019, 8:56am UTC](https://discuss.elastic.co/t/unique-ids-on-jointype-data-structures/180959/2 "2019-06-11T08:56:08Z")

</div>

Closed on June 11, 2019, 8:56am UTC

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