Convert fields of datatype text to int or float in Kibana

Is there a way to convert fields ingested as datatype text to an integer or float in Kibana? It would be cool to be able to convert datatypes real time when creating a visual

You can convert data real time using scripted fields but the performance implications are huge (it will be a lot slower than having those fields indexed as correct data type)


I'm not understanding how to use scripted fields to convert a field into an integer or float.
I've accessed the "Add scripted field" option under Management through the KB interface but do not get the syntax when typing in the script.

All I want to do is convert a field name, let's call it A from datatype keyword to datatype integer. And I want to convert another field name, let's call it B from datatype keyword to datatype float.

Thanks in advance!

Alternatively, is there a way to convert values in a set of key-value pairs to an integer or float if it is indeed an int or float? That way I can ingest the fields into Kibana as integers/floats already rather than converting in the interface.