# How to get a distinct list of keys of a dictionary field

**URL:** <https://discuss.elastic.co/t/how-to-get-a-distinct-list-of-keys-of-a-dictionary-field/110218>\
**Category:** Elasticsearch\
**Created:** [December 4, 2017, 10:11pm UTC](https://discuss.elastic.co/t/how-to-get-a-distinct-list-of-keys-of-a-dictionary-field/110218 "2017-12-04T22:11:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TaiVo](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@TaiVo](https://discuss.elastic.co/u/TaiVo)\
**Post date:** [December 4, 2017, 10:11pm UTC](https://discuss.elastic.co/t/how-to-get-a-distinct-list-of-keys-of-a-dictionary-field/110218/1 "2017-12-04T22:11:40Z")

</div>

Hi, I have a field, which is a dictionary stored inside the \_source as follows:

"dict\_field": {  
"key1": value,  
"key2": value,  
"key3": value,  
....  
}

I don't know all the possible keys, and I'd like to write an es query to return a list of the distinct keys. I tried the standard terms query, but it didn't work. Does anyone know how to do this?

Thank you!

---

<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:** [January 1, 2018, 10:11pm UTC](https://discuss.elastic.co/t/how-to-get-a-distinct-list-of-keys-of-a-dictionary-field/110218/2 "2018-01-01T22:11:57Z")

</div>

Closed on January 1, 2018, 10:11pm UTC

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