Check out runtime fields in the Lens UI instead of stack management (it's newer as of 7.13) - Lens | Kibana Guide [7.13] | Elastic
You can add a script that converts the field to the appropriate data type. Really, though, if this works for you it's more performant to index the appropriate type up front (runtime fields are slower than indexed fields).
Here's an example that does the opposite of what you're trying to do. The example uses painless which exposes a lot of useful java APIs.
Long input = doc['event.duration'].value;
String output = Objects.toString(input);