# Why event.code has string type?

**URL:** <https://discuss.elastic.co/t/why-event-code-has-string-type/199678>\
**Category:** Beats\
**Tags:** ecs-elastic-common-schema, winlogbeat\
**Created:** [September 16, 2019, 2:24pm UTC](https://discuss.elastic.co/t/why-event-code-has-string-type/199678 "2019-09-16T14:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smerzlyakov](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@smerzlyakov](https://discuss.elastic.co/u/smerzlyakov)\
**Post date:** [September 16, 2019, 2:24pm UTC](https://discuss.elastic.co/t/why-event-code-has-string-type/199678/1 "2019-09-16T14:24:58Z")

</div>

Hello. Why event.code has string type and not number by default?Thats why i can't properly filter. If you filter by 7 - you find a lot of - 4557, 4755, 4575 and so on. Also, you cant use ranges.

---

<div class="post-metadata">

**Author:** ![webmat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webmat/32/46191_2.png) [@webmat](https://discuss.elastic.co/u/webmat)\
**Post date:** [October 8, 2019, 5:22pm UTC](https://discuss.elastic.co/t/why-event-code-has-string-type/199678/2 "2019-10-08T17:22:44Z")

</div>

Hello, `event.code` is of datatype `keyword` because not all event sources use numeric event codes.

If you need this value as a numeric, you're more than welcome to duplicate the value to a custom field of your choice, using the datatype of your choice 🙂

---

<div class="post-metadata">

**Author:** ![webmat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webmat/32/46191_2.png) [@webmat](https://discuss.elastic.co/u/webmat)\
**Post date:** [October 8, 2019, 5:27pm UTC](https://discuss.elastic.co/t/why-event-code-has-string-type/199678/3 "2019-10-08T17:27:18Z")

</div>

Note that with the keyword field you can do wildcards: `event.code:45*` will match 45, 455, 4557, 4575

Another option if you're looking for a very specific list of values is to pass in the exact list: `event.code:(4557 or 4755 or 4575)`. You can [learn more here](https://www.elastic.co/guide/en/kibana/current/kuery-query.html)

---

<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:** [November 5, 2019, 5:27pm UTC](https://discuss.elastic.co/t/why-event-code-has-string-type/199678/4 "2019-11-05T17:27:28Z")

</div>

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