# Field conversion to integer

**URL:** https://discuss.elastic.co/t/field-conversion-to-integer/89739
**Category:** Logstash
**Created:** [June 16, 2017, 3:43pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739 "2017-06-16T15:43:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pmohan](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@pmohan](https://discuss.elastic.co/u/pmohan)
#### Post date: [June 16, 2017, 3:43pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739/1 "2017-06-16T15:43:55Z")

</div>

Hi,

I'm new to this elastic serach\logstash world !  
This is one filed(extra\_fields) that i'm working on at the mint  
| /PublishingServices/ **/events/** : 6| /PublishingServices/ **/sport: 1| /PublishingServices/** /event: 12

So the field extra\_fields has valued | /PublishingServices/ **/events/** : 6| /PublishingServices/ **/sport: 1| /PublishingServices/** /event: 12  
kv {  
source =\> extra\_fields  
field\_split =\> "|"  
recursive =\> "true"  
trim\_key =\> "\s"  
value\_split =\> ":"  
}

and i wan the filed that's created after the value split to be integer is that possible ? I always get it as string ☹

Please help me with few ideas !  
Thanks,  
Prabu

---

<div class="post-metadata">

### Author: ![Kryten](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@Kryten](https://discuss.elastic.co/u/Kryten)
#### Post date: [June 16, 2017, 4:18pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739/2 "2017-06-16T16:18:08Z")

</div>

I found your description of the problem quite difficult to follow.

If you have a specific field which contains a string for example "44" and you need to convert it to an integer you could use the convert function in the mutate filter as so:

```
if [extra_fields] {
    mutate {
        convert => { "extra_fields" => "integer" }
    }
}
```

---

<div class="post-metadata">

### Author: ![pmohan](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@pmohan](https://discuss.elastic.co/u/pmohan)
#### Post date: [June 19, 2017, 1:51pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739/3 "2017-06-19T13:51:44Z")

</div>

Sorry for the confusion!

After parsing a log through log stash i want to do a split on the field names "Extra\_Fields" recursively and value split on ":"

I've achieved the above using KV filter below  
extra\_fields:"| /PublishingServices/ **/events/** : 6| /PublishingServices/ **/sport: 1| /PublishingServices/** /event: 12"  
kv {  
source =\> extra\_fields  
field\_split =\> "|"  
recursive =\> "true"  
trim\_key =\> "\s"  
value\_split =\> ":"  
}

All i want to do is set the Fields that created after the KV split to be integer they are set as string ;-(

if i use the dynamic numeric detection to true on mapping it works only on the first index ( i created new index per day) the index created the next day dosnt detect the dynamic mapping and changes the type to string causing field conflicts

Hope its clear now and help would be appreciated .

---

<div class="post-metadata">

### Author: ![pmohan](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@pmohan](https://discuss.elastic.co/u/pmohan)
#### Post date: [June 20, 2017, 12:10pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739/4 "2017-06-20T12:10:37Z")

</div>

Hi team,

Any advice on this issue ?

Thanks,  
Prabu

---

<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 18, 2017, 12:10pm UTC](https://discuss.elastic.co/t/field-conversion-to-integer/89739/5 "2017-07-18T12:10:44Z")

</div>

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