How to add fields with special characters using painless scripting(Java ES SDK)

Hi All,

I am using ES Java SDK for my insert/update operation. I am using "update by query" with painless scripting. Everything works well but I am facing issues while indexing data with special characters. Please find below what I am trying to achieve.

String bundlescript = "ctx._source.content.metadata.emfAttributes.3+=params.3+";
params.3+ is a map(bundleparameters). so basically the map will have value like - {3+=xyz}
my requirement is to get the data in Es in the below format
But while running I am getting an script_exception because of the + symbol. Tried escaping and adding single/double quotes but to no use

short code:

Map<String, Object> bundleParameters;
String bundlescript = "ctx._source.content.metadata.emfAttributes.3+=params.3+";
Script script = new Script(ScriptType.INLINE, "painless", bundleScript, bundleParameters);				updateByQueryRequest.setQuery(boolQueryBuilder).setScript(script)

Any help would be highly appreciated