Index duplicate documents with the different routing id

When I try to index two similar documents (in my case, these are customers) with the same id and a different routing id, I get the first document is created, but the second document is updated.

As I know, I can index two similar documents with different routing id.

Here is my mapping:

{
    "estimate-index": {
        "mappings": {
            "_routing": {
                "required": true
            },
            "properties": {
                "id": {
                    "type": "keyword"
                },
                "joinField": {
                    "type": "join",
                    "eager_global_ordinals": true,
                    "relations": {
                        "estimate": [
                            "customer"
                        ]
                    }
                },
                "name": {
                    "type": "text"
                },
                "number": {
                    "type": "text"
                },
                "parent": {
                    "type": "integer"
                }
            }
        }
    }
}

The routing value determines which shard a document is routed to but it does not guarantee that two documents with different routing IDs will go to different shards. If the documents have the same ID and the routing value resolves to the same shard only the latest will be kept. You can easily see this by indexing a number of documents (3 or more) with the same ID but different routing IDs into an index with just 2 primary shards and see how many total documents are reported..

How can I organize such a relationship? I would like to store many documents that can point to one document.

I am not sure I understand the question. Can you give an example? What do you mean by "I would like to store many documents that can point to one document."?

For example, I want to index a two-child document that has the same ID and different routing IDs. But, as far as I understand, the parent/child relationship doesn't allow it. How can I get around this limitation?

As far as I know you can not. Instead give the documents unique IDs.

Thank you.

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