gpt4 book ai didi

elasticsearch - 用Elasticsearch进行Groovy编程

转载 作者:行者123 更新时间:2023-12-03 01:52:13 24 4
gpt4 key购买 nike

我是新手。我已经编写了用于Elasticsearch Watcher条件的简单程序,但是在MissingMethodException日志语句之后,它正在获取异常FOR IN

FOR IN
[2016-09-08 16:42:42,654][ERROR][watcher.condition.script ] [elk-node] failed to execute [script] condition for [testwatch_12-2016-09-08T16:42:42.608Z]
ScriptException[failed to run file script [validateScore] using lang [groovy]]; nested: MissingMethodException[No signature of method: de52a242cfec68298fc9cbef740d5b0e4d4112b0.$() is applicable for argument types: (de52a242cfec68298fc9cbef740d5b0e4d4112b0$_run_closure1) values: [de52a242cfec68298fc9cbef740d5b0e4d4112b0$_run_closure1@31787094]
Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)];
at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:320)
at org.elasticsearch.watcher.condition.script.ExecutableScriptCondition.doExecute(ExecutableScriptCondition.java:67)
at org.elasticsearch.watcher.condition.script.ExecutableScriptCondition.execute(ExecutableScriptCondition.java:54)
at org.elasticsearch.watcher.condition.script.ExecutableScriptCondition.execute(ExecutableScriptCondition.java:36)
at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:368)
at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)
at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:438)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

def thres = ${threshold}
println "${ctx.payload.hits.hits[0]._score}"
def result = false
def score = ${hit._score}


for(hit in ctx.payload.hits.hits){
println "FOR IN"
if (${score} > ${thres}) {
println "Inside Condition IF"
result = true
}
}

ElasticSearch Watcher条件

"condition": { "script" : { "file" : "validateScore", "lang": "groovy", "params" : { "threshold" : 1.09 } } },

最佳答案

仅供引用,这可能是您更好的解决方案

result = ctx.payload.hits.hits.any { score > thres }

关于elasticsearch - 用Elasticsearch进行Groovy编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39396834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com