I am trying to run the Update api using Inline Scripting ,my code is
client.prepareUpdate("result",typeName, "1")
.setScript(new Script("ctx._source.gender=doc['"+AggregateValue_First+"'].value*doc['"+AggregateValue_Second+"'].value",ScriptType.INLINE, null, null))
.get();
When I am executing it , i am getting
java.lang.IllegalArgumentException: failed to execute script
my log looks like
Caused by: ScriptException[failed to run inline script
[ctx._source.gender =
doc['AVG_PRICE_PER_UNIT'].value*doc['NUMBER_OF_UNITS'].value] using
lang [groovy]]; nested:
NotSerializableExceptionWrapper[missing_property_exception: No such
property: doc for class: af9b76c11012333a0eeba6af6df35125322f36b8];
at
org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:320)
at
org.elasticsearch.action.update.UpdateHelper.executeScript(UpdateHelper.java:252)... 14 more
Caused by: NotSerializableExceptionWrapper[missing_property_exception:
No such property: doc for class:
af9b76c11012333a0eeba6af6df35125322f36b8] at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at
org.codehaus.groovy.vmplugin.v7.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:177)
at
org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:228)
at
af9b76c11012333a0eeba6af6df35125322f36b8.run(af9b76c11012333a0eeba6af6df35125322f36b8:1)
at
org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript$1.run(GroovyScriptEngineService.java:313)
at java.security.AccessController.doPrivileged(Native Method) at
org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:310)
... 15 more
Can someone help me with this?
i tried
client.prepareUpdate("result",typeName,"1").setScript(newScript("ctx._source.gender.value = ctx._source['"+AggregateValue_First+"'].value * ctx._source['"+AggregateValue_Second+"'].value", ScriptType.INLINE, null, null)) .get();
now the error is something like
log4j:WARN No appenders could be found for logger (org.elasticsearch.node). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. java.lang.IllegalArgumentException: failed to execute script at org.elasticsearch.action.update.UpdateHelper.executeScript(UpdateHelper.java:257) at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:197) at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:80) at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:174) at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:168) at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:66) at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:244) at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:240) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75) at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.doRun(MessageChannelHandler.java:300) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: ScriptException[failed to run inline script [ctx._source.gender.value = ctx._source['AVG_PRICE_PER_UNIT'].value * ctx._source['5'].value] using lang [groovy]]; nested: AssertionError[BUG! UNCAUGHT EXCEPTION: member is private: java.lang.Integer.value/int/getField, from org.codehaus.groovy.vmplugin.v7.IndyInterface]; nested: NotSerializableExceptionWrapper[illegal_access_exception: member is private: java.lang.Integer.value/int/getField, from org.codehaus.groovy.vmplugin.v7.IndyInterface]; at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:320) at org.elasticsearch.action.update.UpdateHelper.executeScript(UpdateHelper.java:252) ... 14 more Caused by: java.lang.AssertionError: BUG! UNCAUGHT EXCEPTION: member is private: java.lang.Integer.value/int/getField, from org.codehaus.groovy.vmplugin.v7.IndyInterface at org.codehaus.groovy.vmplugin.v7.Selector$PropertySelector.chooseMeta(Selector.java:311) at org.codehaus.groovy.vmplugin.v7.Selector$MethodSelector.setCallSiteTarget(Selector.java:954) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:224) at a45669ea4b74cc2cb4371072fd14ab69cb5dd5f6.run(a45669ea4b74cc2cb4371072fd14ab69cb5dd5f6:1) at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript$1.run(GroovyScriptEngineService.java:313) at java.security.AccessController.doPrivileged(Native Method) at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:310) ... 15 more Caused by: NotSerializableExceptionWrapper[illegal_access_exception: member is private: java.lang.Integer.value/int/getField, from org.codehaus.groovy.vmplugin.v7.IndyInterface] at java.lang.invoke.MemberName.makeAccessException(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.checkAccess(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.checkField(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.getDirectFieldCommon(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.getDirectFieldNoSecurityManager(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.unreflectField(Unknown Source) at java.lang.invoke.MethodHandles$Lookup.unreflectGetter(Unknown Source) at org.codehaus.groovy.vmplugin.v7.Selector$PropertySelector.chooseMeta(Selector.java:302) ... 21 more