# Find the distinct values under the nested type

**URL:** <https://discuss.elastic.co/t/find-the-distinct-values-under-the-nested-type/156341>\
**Category:** Elasticsearch\
**Created:** [November 12, 2018, 7:43pm UTC](https://discuss.elastic.co/t/find-the-distinct-values-under-the-nested-type/156341 "2018-11-12T19:43:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepak643](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepak643/32/45940_2.png) [@deepak643](https://discuss.elastic.co/u/deepak643)\
**Post date:** [November 12, 2018, 7:43pm UTC](https://discuss.elastic.co/t/find-the-distinct-values-under-the-nested-type/156341/1 "2018-11-12T19:43:37Z")

</div>

I am trying to group the distinct values under the nested type. I am having hard time finding the query for this. Any suggestions would be appreciated.

My data looks like below:

```
[
{
  objectID: "xxx",
  admin : {
      "org" : "123"
  },
  info : {
    ...
    "ID" : "000"
    ...
  }
},
{
  objectID: "xxx_x",
  admin : {
      "org" : "123"
  },
  info : {
    ...
    "ID" : "001"
    ...
  }
},
{
  objectID: "xxx_xx",
  admin : {
      "org" : "234"
  },
  info : {
    ...
    "ID" : "111"
    ...
  }
}
]

```

For the above data, I am trying to get all the distinct "info ID's" for the given "admin org".

As org is in one nested type (admin)  
and info ID is another nested type (info).. I do not understand how to achieve the result.

The result I am looking for is something like:

```
{
  org : 123 ,         
  IDs : [000, 001]
}
```

---

<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 10, 2018, 7:46pm UTC](https://discuss.elastic.co/t/find-the-distinct-values-under-the-nested-type/156341/2 "2018-12-10T19:46:53Z")

</div>

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