# Store enum as keyword VS integer

**URL:** <https://discuss.elastic.co/t/store-enum-as-keyword-vs-integer/257903>\
**Category:** Elasticsearch\
**Created:** [December 7, 2020, 7:33pm UTC](https://discuss.elastic.co/t/store-enum-as-keyword-vs-integer/257903 "2020-12-07T19:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lang1991](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lang1991](https://discuss.elastic.co/u/lang1991)\
**Post date:** [December 7, 2020, 7:33pm UTC](https://discuss.elastic.co/t/store-enum-as-keyword-vs-integer/257903/1 "2020-12-07T19:33:31Z")

</div>

We have a layer on top of Elasticsearch to translate enums into their numeric values before querying and indexing, but I am wondering if that's necessary at all for storage savings and query performance when compared with storing these enums as keywords.  
From this post a long time ago: [Are ENUM stored efficiently?](https://discuss.elastic.co/t/are-enum-stored-efficiently/63361), it seems storing enum values as keywords is already the optimized way?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 8, 2020, 12:53am UTC](https://discuss.elastic.co/t/store-enum-as-keyword-vs-integer/257903/2 "2020-12-08T00:53:27Z")

</div>

We try to optimise all data structures, irrespective of their underlying type.

And I can't quantify this, but if they are actually numeric it seems to me converting them seems to be a the best approach as you're explicitly setting them, rather than treating it as a number in a text field.

---

<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 5, 2021, 12:53am UTC](https://discuss.elastic.co/t/store-enum-as-keyword-vs-integer/257903/3 "2021-01-05T00:53:39Z")

</div>

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