# Add numeric field

**URL:** https://discuss.elastic.co/t/add-numeric-field/205685
**Category:** Logstash
**Created:** [October 29, 2019, 1:55pm UTC](https://discuss.elastic.co/t/add-numeric-field/205685 "2019-10-29T13:55:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RickT](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RickT](https://discuss.elastic.co/u/RickT)
#### Post date: [October 29, 2019, 1:55pm UTC](https://discuss.elastic.co/t/add-numeric-field/205685/1 "2019-10-29T13:55:05Z")

</div>

Hi,  
i simply want to create a new numeric field.  
But when using "add-field" command i get systematically a string !  
My logstash filter code like :  
....  
mutate { add\_field =\> { "launcher.%{company}" =\> "%{count\_comp}"} }  
mutate { convert =\> ["launcher.%{company}","float\_eu"] }  
....

I tried with type "integer" but it's the same result.

Expected result in es is :

> > "launcher.ABC" = "12.10"  
> > "launcher.DEF" = "33.00"

Where is my mistake ?  
Thanks

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 29, 2019, 2:06pm UTC](https://discuss.elastic.co/t/add-numeric-field/205685/2 "2019-10-29T14:06:52Z")

</div>

add\_field always adds strings. You can use mutate+convert to change it to a number. Note that convert gets executed before add\_field, so it has to be a separate mutate filter.

---

<div class="post-metadata">

### Author: ![RickT](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RickT](https://discuss.elastic.co/u/RickT)
#### Post date: [October 29, 2019, 2:35pm UTC](https://discuss.elastic.co/t/add-numeric-field/205685/3 "2019-10-29T14:35:43Z")

</div>

> [@Badger](#):
>
> Note that convert gets executed before add\_field, so it has to be a separate mutate filter.

Thanks Badger,  
but that does not solve the problem (logstash 6.8). I don't understand...

Finally, I mapped the field directly in es before running Logstash. That solved the problem.

---

<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 26, 2019, 2:35pm UTC](https://discuss.elastic.co/t/add-numeric-field/205685/4 "2019-11-26T14:35:46Z")

</div>

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