# Trying to divide the cardinality of a string/hash field by the numeric value of another field

**URL:** <https://discuss.elastic.co/t/trying-to-divide-the-cardinality-of-a-string-hash-field-by-the-numeric-value-of-another-field/293374>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [January 3, 2022, 4:41pm UTC](https://discuss.elastic.co/t/trying-to-divide-the-cardinality-of-a-string-hash-field-by-the-numeric-value-of-another-field/293374 "2022-01-03T16:41:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjammin92](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjammin92](https://discuss.elastic.co/u/jjammin92)\
**Post date:** [January 3, 2022, 4:41pm UTC](https://discuss.elastic.co/t/trying-to-divide-the-cardinality-of-a-string-hash-field-by-the-numeric-value-of-another-field/293374/1 "2022-01-03T16:41:17Z")

</div>

I'm trying to create a runtime field within an index template. I can easily divide the values of two integers like this:

`emit(doc['bounce_time'].value / doc['session'].value)`

EG  
`bounce_time: 100 / session: 25 = 4`

However I have a hash field that is essentially a uuid. Instead of dividing the `bounce_time` by the `session` Id like to divide the `bounce_time` by the cardinality of the field `uuid`: `emit(doc['bounce_time'].value / doc['uuid'].value)`.

I'm not entirely sure how to get the cardinality of the `uuid` string field before doing the division. Any help?

Thanks

---

<div class="post-metadata">

**Author:** ![jjammin92](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjammin92](https://discuss.elastic.co/u/jjammin92)\
**Post date:** [January 4, 2022, 9:10pm UTC](https://discuss.elastic.co/t/trying-to-divide-the-cardinality-of-a-string-hash-field-by-the-numeric-value-of-another-field/293374/2 "2022-01-04T21:10:07Z")

</div>

Just pinging 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:** [February 1, 2022, 9:10pm UTC](https://discuss.elastic.co/t/trying-to-divide-the-cardinality-of-a-string-hash-field-by-the-numeric-value-of-another-field/293374/3 "2022-02-01T21:10:40Z")

</div>

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