# String as Hash

**URL:** <https://discuss.elastic.co/t/string-as-hash/54258>\
**Category:** Elasticsearch\
**Created:** [June 29, 2016, 10:19am UTC](https://discuss.elastic.co/t/string-as-hash/54258 "2016-06-29T10:19:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sundar\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundar_v/32/6928_2.png) [@Sundar\_V](https://discuss.elastic.co/u/Sundar_V)\
**Post date:** [June 29, 2016, 10:19am UTC](https://discuss.elastic.co/t/string-as-hash/54258/1 "2016-06-29T10:19:47Z")

</div>

Hi,

We have many string values, which we are indexing as `not_analyzed`. Our main aim is only to aggregate these values.

For using these strings in our REST API, we would prefer to have it as a MD5Hash (in the field `urlHash`), so that it looks cleaner. The issue is, for this to work, I have to save the original string as it is, and also the `urlHash` too.

And when I aggregate, I have to aggregate based on the string and use "Top Hit Aggregate" to fetch the `urlHash` too in the aggregate result.

Is there a better approach than this?

---

<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:39pm UTC](https://discuss.elastic.co/t/string-as-hash/54258/2 "2017-07-05T22:39:38Z")

</div>


