# Mutating several fields at once

**URL:** https://discuss.elastic.co/t/mutating-several-fields-at-once/175402
**Category:** Logstash
**Created:** [April 4, 2019, 12:12pm UTC](https://discuss.elastic.co/t/mutating-several-fields-at-once/175402 "2019-04-04T12:12:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)
#### Post date: [April 4, 2019, 12:12pm UTC](https://discuss.elastic.co/t/mutating-several-fields-at-once/175402/1 "2019-04-04T12:12:35Z")

</div>

Hi Guys,

I'm looking for a more efficient way to convert my fields. My output looks like this:

```
"id" => 1.0
"code" => 200.0
"name" => "Something "
"middlename" => " Hok"
"lastname" => "Something as well"

```

I need to convert my numeric values to integers and strip all whitespaces from string fields.  
Normally I would use simple operations:

> mutate {  
> convert =\> {  
> "id" =\> "integer"  
> "code" =\> "integer"  
> }  
> strip =\> ["name", "middlename", "lastname"]  
> }

And that's ok for a few fields. But let's assume i have around 100 of each type and doing the same for all of them might be problematic. Is there a more efficient way to do it? Ruby, conditional statement? If so, what would be the code to achieve it?  
Thanks in advance!

---

<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: [May 2, 2019, 12:12pm UTC](https://discuss.elastic.co/t/mutating-several-fields-at-once/175402/2 "2019-05-02T12:12:37Z")

</div>

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