It's better IMHO to do that before sending documents to elasticsearch.
You may want to look at Logstash if this suits your needs but if you already have an application which is generating the data, I'd try to do that transformation within the application.
1 Like