# Tried "mutate" convert", logstash getting error from elasticsearch: "type \[float\] to \[long\]"

**URL:** https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356
**Category:** Elasticsearch
**Created:** [December 17, 2021, 6:17pm UTC](https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356 "2021-12-17T18:17:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![4art4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/4art4/32/98919_2.png) [@4art4](https://discuss.elastic.co/u/4art4)
#### Post date: [December 17, 2021, 6:17pm UTC](https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356/1 "2021-12-17T18:17:38Z")

</div>

My expectation is that adding the 'convert' would insure that all data for that field will be of type "float", but I guess I did it wrong?

relevant part of data:

```auto
"metrics"=>[
	{
		"Unit"=>"Count", 
		"MetricName"=>"ResourceCount", 
		"Timestamp"=>"2021-11-22T15:31:50.684999", 
		"Value"=>2
	}, 
	{
		"Unit"=>"Seconds", 
		"MetricName"=>"ResourceTime", 
		"Timestamp"=>"2021-11-22T15:31:50.685014", 
		"Value"=>0.4867427349090576e0
	}, 
	{
		"Unit"=>"Count", 
		"MetricName"=>"PolicyException", 
		"Timestamp"=>"2021-11-22T15:31:51.170848", 
		"Value"=>1
	}
],

```

mutate:

```auto
    mutate {
        convert => {
            "[cc-data][metrics][Value]" => "float"
        }
        remove_field => ["message", "@timestamp", "@version", "host"]
    }

```

but got error:

```auto
Could not index event to Elasticsearch. {:status=>400,
...
"status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [cc-data.metrics.Value] cannot be changed from type [float] to [long]"}}}}

```

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [December 17, 2021, 6:24pm UTC](https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356/2 "2021-12-17T18:24:19Z")

</div>

This has to be done in the [index mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html). The data types in Logstash don't translate over to Elastic and are only used internally to Logstash.

---

<div class="post-metadata">

### Author: ![4art4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/4art4/32/98919_2.png) [@4art4](https://discuss.elastic.co/u/4art4)
#### Post date: [December 17, 2021, 6:25pm UTC](https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356/3 "2021-12-17T18:25:32Z")

</div>

Thank you so much for your help!

---

<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: [January 14, 2022, 6:26pm UTC](https://discuss.elastic.co/t/tried-mutate-convert-logstash-getting-error-from-elasticsearch-type-float-to-long/292356/4 "2022-01-14T18:26:02Z")

</div>

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