String Replace in Painless

I tried the following replace, and it did not work. Seems to be returning the empty string. Is this the correct way to do a string replace? Note that what I found on this thread does not seem to work for me. Replace string in a string field (Ingest Pipeline)

for(def hit: ctx.payload.hits.hits) {
    formattedMessage = hit._source.message.replace('{', '<')
    formattedMessage = formattedMessage.replace('}', '>')

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