# Duplicate documents with exactly same index/type/id in ES5.4.2

**URL:** https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683
**Category:** Elasticsearch
**Created:** [November 15, 2017, 8:01am UTC](https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683 "2017-11-15T08:01:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zhangke](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zhangke](https://discuss.elastic.co/u/zhangke)
#### Post date: [November 15, 2017, 8:01am UTC](https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683/1 "2017-11-15T08:01:44Z")

</div>

My ES cluster has only one node. The "model" index has 5 primary shards and 1 replica shard.

After indexing several documents, I run the below query:

> GET [https://9.111.255.174:9200/model/cubes/\_search](https://9.111.255.174:9200/model/cubes/_search)

The response is as below.

```
{
  "took": 21,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 1,
    "hits": [
      {
        "_index": "model",
        "_type": "cubes",
        "_id": "slot_allocation_cube_1",
        "_score": 1,
        "_source": {
         ......
        }
      },
      {
        "_index": "model",
        "_type": "cubes",
        "_id": "slot_allocation_cube_1",
        "_score": 1,
        "_source": {
        ......
        }
      }
    ]
  }
}

```

We can see that there are two duplicated documents with the same "\_id" as "slot\_allocation\_cube\_1". **I'm sure I didn't use customer routing during data indexing.**

After investigation, I find the data is correct on shard 0. However, there is something wrong with shard 3.

I run the below query

> GET [https://9.111.255.174:9200/model/cubes/\_search?preference=\_shards:](https://9.111.255.174:9200/model/cubes/_search?preference=_shards:) 3

The response is as below.

```
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "model",
        "_type": "cubes",
        "_id": "slot_allocation_cube_1",
        "_score": 1,
        "_source": {
         ......
        }
      }
    ]
  }
}

```

However, when I specify the id and run the below query

> GET [https://9.111.255.174:9200/model/cubes/slot\_allocation\_cube\_1?preference=\_shards:3](https://9.111.255.174:9200/model/cubes/slot_allocation_cube_1?preference=_shards:3)

It failed!!!

```
 {
      "error": {
        "root_cause": [
          {
            "type": "remote_transport_exception",
            "reason": "[client_jfp4][9.111.255.174:9300][indices:data/read/get[s]]"
          }
        ],
        "type": "null_pointer_exception",
        "reason": null
      },
      "status": 500
    }

```

It is really strange. Can someone help me on this? Thanks a million!!!

---

<div class="post-metadata">

### Author: ![zhangke](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zhangke](https://discuss.elastic.co/u/zhangke)
#### Post date: [November 16, 2017, 8:36am UTC](https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683/2 "2017-11-16T08:36:36Z")

</div>

Could anyone help on this issue?

😭😭😭😭😭😭😭😭😭😭😭

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 16, 2017, 9:31am UTC](https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683/3 "2017-11-16T09:31:53Z")

</div>

What do the logs show when you get that 500 error?

What does the search show if you add `?explain=true` to the end? It should show which shard it is hitting and more.

Can you show your index settings as well?

---

<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: [December 14, 2017, 9:32am UTC](https://discuss.elastic.co/t/duplicate-documents-with-exactly-same-index-type-id-in-es5-4-2/107683/4 "2017-12-14T09:32:05Z")

</div>

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