# Can Logstash convert a string into a version field type?

**URL:** <https://discuss.elastic.co/t/can-logstash-convert-a-string-into-a-version-field-type/356810>\
**Category:** Logstash\
**Created:** [April 4, 2024, 6:37pm UTC](https://discuss.elastic.co/t/can-logstash-convert-a-string-into-a-version-field-type/356810 "2024-04-04T18:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Cook](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_cook/32/133291_2.png) [@Michael\_Cook](https://discuss.elastic.co/u/Michael_Cook)\
**Post date:** [April 4, 2024, 6:37pm UTC](https://discuss.elastic.co/t/can-logstash-convert-a-string-into-a-version-field-type/356810/1 "2024-04-04T18:37:15Z")

</div>

I've come across [Version field type | Elasticsearch Guide [8.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/version.html#version) which describes exactly what I want to do with a semver text field I'm ingesting via Logstash.

However, is it possible in the Logstash filter pipeline to convert the semver string into a version field type? If so, what does the syntax look like?

I am currently letting Logstash set up the mapping for incoming logs and do not manipulate the index mapping.

When I try this under 8.12 ELK stack:

```auto
        mutate {
            add_field => { "semver_version" => "%{version}" }
            convert => { "semver_version" => "version" }
        }                              
    }

```

I get...

```auto
Invalid conversion type 'version', expected one of 'string,integer,float,boolean,integer_eu,float_eu'

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 4, 2024, 6:58pm UTC](https://discuss.elastic.co/t/can-logstash-convert-a-string-into-a-version-field-type/356810/2 "2024-04-04T18:58:02Z")

</div>

> [@Michael\_Cook](#):
>
> However, is it possible in the Logstash filter pipeline to convert the semver string into a version field type?

I don't think so, this is elasticsearch data type, it is unrelated to logstash.

The mutate convert filter has these [options](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-convert), it helps you to convert some fields before sending to elasticsearch when using dynamic mapping, but in the end what matters is the mapping in elasticsearch.

> [@Michael\_Cook](#):
>
> I am currently letting Logstash set up the mapping for incoming logs and do not manipulate the index mapping

If you do not have a template, the mapping is set by Elasticsearch when it receives a field for the first time, using convert in Logstash will help elasticsearch to infer the right data type for a field, but for some specific fields like this one you need to create the mapping in Elasticsearch.

You can do that using `_mapping` API or creating a template for your index.

---

<div class="post-metadata">

**Author:** ![Michael\_Cook](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_cook/32/133291_2.png) [@Michael\_Cook](https://discuss.elastic.co/u/Michael_Cook)\
**Post date:** [April 4, 2024, 7:15pm UTC](https://discuss.elastic.co/t/can-logstash-convert-a-string-into-a-version-field-type/356810/3 "2024-04-04T19:15:56Z")

</div>

Thanks for confirming. I had confused logstash and es having the same types.  
I will generate a mapping.
