If you need to convert it to integer because you want to filter by values or compute aggregations, what you are doing is not going to work.
If the field is still a text, and not a int in the mapping.
So you need to create a new index and reindex your data. That's the best option IMO.
Look at the reindex API. And I would use an ingest pipeline with a convert processor to change your field from string to number on the fly, while reindexing.