我正在尝试使用内联脚本运行Update api,我的代码是
client.prepareUpdate("result",typeName, "1")
.setScript(new Script("ctx._source.gender=doc['"+AggregateValue_First+"'].value*doc['"+AggregateValue_Second+"'].value",ScriptType.INLINE, null, null))
.get();
当我执行它时,我得到
java.lang.IllegalArgumentException: failed to execute script
我的日志看起来像
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
有人可以帮我弄这个吗?
我试过了
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();
现在错误是这样的
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.html" target="_blank">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
尝试以下操作(即使用ctx._source
代替doc
):
client.prepareUpdate("result",typeName, "1")
.setScript(new Script("ctx._source.gender = ctx._source['"+AggregateValue_First+"'] * ctx._source['"+AggregateValue_Second+"']", ScriptType.INLINE, null, null))
.get();
我试图使用内联脚本运行更新api,我的代码是 当我执行它时,我得到 现在的错误类似于
我得到了一个使用thymeleaf模板的页面,当使用内联脚本时,我在页面加载时遇到以下错误: 组织。xml。萨克斯。SAXS异常;行号:270;栏目号:85;元素的内容必须由格式良好的字符数据或标记组成。 代码在270行 我试过替换“
我正在从chargebee.com加载外部脚本,并在控制台中收到此错误消息: [仅报告]拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script src'nonce VVZ V0c=''self'https://maps.googleapis.com https://domain.chargebeestatic.com http://dgkxwewtzsnml.cloudfront.ne
问题内容: 我习惯像这样包含和使用JS: 出于好奇,有人知道使用src属性的内联脚本的规则,例如: 我可以测试在各种浏览器中会发生什么,但想知道官方行为是什么。 问题答案: 这是一个或另一个,而不是两者兼而有之。标签的属性优先于标签的主体。 [HTML 4.01规范: 该脚本可以在SCRIPT元素的内容内或在外部文件中定义。如果未设置该属性,则用户代理必须将元素的内容解释为脚本。如果具有URI值,
我一直得到这个错误: 拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“default-src'self'data:gap:http://www.visitsingapore.com https://ssl.gstatic.com'unsafe-eval'”。“unsafe-inline”关键字、哈希('sha256-v+/u3qbjhkp0sanqhmwynm62gfwx4qhwpj7we1
问题内容: 我有一个问题: 虽然我从另一个带有ajax的页面调用内联脚本(也使用jQuery),但似乎不再定义jQuery(?),并且我无法使用任何jQuery函数,应该使用(根据内联脚本)。 它基本上是新闻列表,其中包含指向特定新闻项目的链接。我现在更喜欢使用内联脚本,因为在其他地方不需要此功能。 如您所见,我只是在调用另一个页面的一部分并将其内容附加到页面上。 当我加载整个页面(不是页面的一部