# Finding Duplicates from an index with nested field

**URL:** <https://discuss.elastic.co/t/finding-duplicates-from-an-index-with-nested-field/280634>\
**Category:** Kibana\
**Created:** [August 6, 2021, 9:37am UTC](https://discuss.elastic.co/t/finding-duplicates-from-an-index-with-nested-field/280634 "2021-08-06T09:37:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fastkt](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@fastkt](https://discuss.elastic.co/u/fastkt)\
**Post date:** [August 6, 2021, 9:37am UTC](https://discuss.elastic.co/t/finding-duplicates-from-an-index-with-nested-field/280634/1 "2021-08-06T09:37:33Z")

</div>

Hi I am fairly new to ES and need some help.  
I have an index

```auto
{
  "shop_index": {
    "properties": {
      "shop_key": {
        "type": "nested",
        "properties": {
          "shop_id": "keyword",
          "shop_number": "long"
        }
      }
    }
  }
}

```

Now in some cases we are storing some shops with the same shop\_key so same shop\_id and shop\_number, i just need to find these records on ES, i tried with nested aggregation but doesnt give the result also i tried with script "doc['shop\_key.shop\_id'].value + String.valueOf(doc['shop\_number'].value)" but this doesnt return the correct doc\_count for duplicate records.  
Can you suggest something.  
Sorry if the code is bad , i just started with ES 3 days back 🙂 so still lot to learn.

---

<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:** [September 3, 2021, 9:38am UTC](https://discuss.elastic.co/t/finding-duplicates-from-an-index-with-nested-field/280634/2 "2021-09-03T09:38:27Z")

</div>

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