# Select distinct values of nested field

**URL:** <https://discuss.elastic.co/t/select-distinct-values-of-nested-field/49112>\
**Category:** Elasticsearch\
**Created:** [May 3, 2016, 9:52pm UTC](https://discuss.elastic.co/t/select-distinct-values-of-nested-field/49112 "2016-05-03T21:52:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [May 3, 2016, 9:52pm UTC](https://discuss.elastic.co/t/select-distinct-values-of-nested-field/49112/1 "2016-05-03T21:52:10Z")

</div>

I've got a nested type for identifiers (e.g. full name, given name, surname, etc.) on which i'd like to return the unique values for a nested field. The data is like the following:  
`{ "entityType" : "Person", "identifier" : [{ "idType" : "Full Name", "value" : "Smith, John" }, { "idType" : "Given Name", "value" : " John" }, { "idType" : "Surname", "value" : "Smith" }, { "idType" : "AKA", "value" : "John the Great" }] }`  
What would be the most effective way to return the distinct values for identifier.value for entityType = "Person" AND idType = "Full Name"? Note that idType = "Full Name" could also be for docs other than Person; e.g. idType = "Organization".

BTW, I'm using elasticsearch 1.7.1.

Thoughts?

---

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [May 4, 2016, 1:24pm UTC](https://discuss.elastic.co/t/select-distinct-values-of-nested-field/49112/2 "2016-05-04T13:24:15Z")

</div>

If the answer is that it's not possible, that would be a helpful reply 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:** [July 5, 2017, 10:53pm UTC](https://discuss.elastic.co/t/select-distinct-values-of-nested-field/49112/3 "2017-07-05T22:53:59Z")

</div>


