# How to get distinct keys from nested object

**URL:** <https://discuss.elastic.co/t/how-to-get-distinct-keys-from-nested-object/165994>\
**Category:** Elasticsearch\
**Created:** [January 28, 2019, 11:36am UTC](https://discuss.elastic.co/t/how-to-get-distinct-keys-from-nested-object/165994 "2019-01-28T11:36:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sesha](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@sesha](https://discuss.elastic.co/u/sesha)\
**Post date:** [January 28, 2019, 11:36am UTC](https://discuss.elastic.co/t/how-to-get-distinct-keys-from-nested-object/165994/1 "2019-01-28T11:36:58Z")

</div>

I am trying to get distinct keys (key1, key2 ..) from a nested object as below example.  
`  
{  
"labels": {  
"key1": "value",  
"key2": "value",  
"key3": "value",  
"key4": "value"  
}  
}  
I dont know , how to aggreagate distinct keys from nested object.

---

<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:** [February 25, 2019, 11:37am UTC](https://discuss.elastic.co/t/how-to-get-distinct-keys-from-nested-object/165994/2 "2019-02-25T11:37:00Z")

</div>

Closed on February 25, 2019, 11:37am UTC

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