# Can not convert from long to float logstash

**URL:** <https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577>\
**Category:** Logstash\
**Created:** [February 15, 2019, 12:03pm UTC](https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577 "2019-02-15T12:03:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KashiPashoria\_Tonny](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@KashiPashoria\_Tonny](https://discuss.elastic.co/u/KashiPashoria_Tonny)\
**Post date:** [February 15, 2019, 12:03pm UTC](https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577/1 "2019-02-15T12:03:59Z")

</div>

I'm taking data from sql server to elasticsearch 6.6 using logstash and jdbc. Some of my records are skipped by logstash printing these warning logs:

**[2019-02-15T16:48:52,630][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>"2111348540", :\_index=\>"order\_tracking1", :\_type=\>"orderstracking\_report", :\_routing=\>nil}, #LogStash::Event:0x14b8bcd8], :response=\>{"index"=\>{"\_index"=\>"order\_tracking1", "\_type"=\>"orderstracking\_report", "\_id"=\>"2111348540", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"mapper [forecast\_voice\_rgu] cannot be changed from type [long] to [float]"}}}}**

**....[2019-02-15T16:48:52,867][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>"13625215", :\_index=\>"order\_tracking1", :\_type=\>"orderstracking\_report", :\_routing=\>nil}, #LogStash::Event:0x70e6f34c], :response=\>{"index"=\>{"\_index"=\>"order\_tracking1", "\_type"=\>"orderstracking\_report", "\_id"=\>"13625215", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"mapper [forecast\_total\_rgu] cannot be changed from type [long] to [float]"}}}}**

**........[2019-02-15T16:48:52,872][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>"190215307182245", :\_index=\>"order\_tracking1", :\_type=\>"orderstracking\_report", :\_routing=\>nil}, #LogStash::Event:0x729a53dd], :response=\>{"index"=\>{"\_index"=\>"order\_tracking1", "\_type"=\>"orderstracking\_report", "\_id"=\>"190215307182245", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"mapper [forecast\_total\_rgu] cannot be changed from type [long] to [float]"}}}}**

My 3 records are missing due to these errors. While the fields **[forecast\_total\_rgu],[forecast\_voice\_rgu]** are not long rather floats in my database having values upto 2 decimals. I don't know why logstash is skipping these records printing these logs while logstash doesn't support **long** datatype.

I just created an other test index and re-imported the same data. For this time it skipped 4 other record and imported previous records fairly. I don't understand this random behaviour of logstash.

If anybody can help.

---

<div class="post-metadata">

**Author:** ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)\
**Post date:** [February 15, 2019, 2:10pm UTC](https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577/2 "2019-02-15T14:10:22Z")

</div>

This has little to do with Logstash itself, it's ElasticSearch that's actually rejecting those records. You just see them in your logs because they are propagated back by ElasticSearch.

The reason they are rejected has to do with how each field is mapped during index creation.  
Unless you define an index mapping/template for ElasticSearch to know what data type each specific field is (and also make sure all values are of the same type for that field), it decides that itself based on the first value's type it sees.

You can use Logstash's [mutate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-convert) filter to convert all values in the same type to ensure you avoid those problems in the future.

---

<div class="post-metadata">

**Author:** ![KashiPashoria\_Tonny](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@KashiPashoria\_Tonny](https://discuss.elastic.co/u/KashiPashoria_Tonny)\
**Post date:** [February 18, 2019, 12:23pm UTC](https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577/3 "2019-02-18T12:23:28Z")

</div>

I have already tried but of no use. I've imported data using .csv and it just works fine for me. The issue is only with SQL. The problem you explained should also occur in .csv but it does not.

---

<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:** [March 18, 2019, 12:23pm UTC](https://discuss.elastic.co/t/can-not-convert-from-long-to-float-logstash/168577/4 "2019-03-18T12:23:30Z")

</div>

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