# Is there a better way to convert long to boolean

**URL:** <https://discuss.elastic.co/t/is-there-a-better-way-to-convert-long-to-boolean/151231>\
**Category:** Logstash\
**Created:** [October 5, 2018, 2:55pm UTC](https://discuss.elastic.co/t/is-there-a-better-way-to-convert-long-to-boolean/151231 "2018-10-05T14:55:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OphyTe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ophyte/32/36444_2.png) [@OphyTe](https://discuss.elastic.co/u/OphyTe)\
**Post date:** [October 5, 2018, 2:55pm UTC](https://discuss.elastic.co/t/is-there-a-better-way-to-convert-long-to-boolean/151231/1 "2018-10-05T14:55:56Z")

</div>

I have a field where values are stored as long (0 for false and 1 for true). I wanted to store them as booleans but the boolean convert filter doesn't accept other type than string.

The only way I found to do this is to duplicate the mutate filter like this :

```
filter {
  mutate {
    convert => {
      "myField" => "string"
    }
  }
  mutate {
    convert => {
      "myField" => "boolean"
    }
  }
}

```

Isn't there a better way to do 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:** [November 2, 2018, 2:56pm UTC](https://discuss.elastic.co/t/is-there-a-better-way-to-convert-long-to-boolean/151231/2 "2018-11-02T14:56:02Z")

</div>

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