Elasticsearch JAVA API - Update by script - throws error when field value contains special characters ("&" , " " " , " >" , etc)

Hi ,

When I try to update a field, the field variable (here "body")
contains special characters ("&" , " " " , " >" ....) it throws exception.
ES version : 1.0.0

I have mentioned my code snippet and stack-trace below:

Thanks in advance.

My code snippet:

String body = GetBody();
UpdateResponse ur = client.prepareUpdate("help","help",id)
.setScript("ctx._source.body = "+body)
.execute().actionGet();

Stacktrace :

at
org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:153)
at
org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:80)
at
org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:189)
at
org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:185)
at
org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:64)
at
org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction$1.run(TransportInstanceSingleOperationAction.java:192)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: [Error: unexpected token: known_Y]
[Near : {... CalcQuickBase["known_Y"] > ....}]

[Line: 25, Column: 23]
at
org.elasticsearch.common.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:255)
at
org.elasticsearch.common.mvel2.util.ParseTools.subCompileExpression(ParseTools.java:2115)
at
org.elasticsearch.common.mvel2.ast.DeepAssignmentNode.(DeepAssignmentNode.java:70)
at
org.elasticsearch.common.mvel2.ast.DeepAssignmentNode.(DeepAssignmentNode.java:83)
at
org.elasticsearch.common.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:785)
at
org.elasticsearch.common.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:128)
at
org.elasticsearch.common.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.elasticsearch.common.mvel2.MVEL.compileExpression(MVEL.java:810)
at
org.elasticsearch.script.mvel.MvelScriptEngineService.compile(MvelScriptEngineService.java:84)
at org.elasticsearch.script.ScriptService.compile(ScriptService.java:145)
at org.elasticsearch.script.ScriptService.executable(ScriptService.java:151)
at
org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:147)
... 8 more

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/286106af-af57-4cdb-a219-9d74d061a280%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.