2016-09-08 7 views
0

groovyの新機能です。私はelasticsearchウォッチャー状態で使用される単純なプログラムを書いたが、ログステートメントの後には例外MissingMethodExceptionが得られている。elasticsearchを使用したGroovyプログラミング

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: [[email protected]] 
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ウォッチャーCondision

"条件":{ "スクリプト":{ "ファイル": "validateScore"、 "langの": "かっこいい"、 "paramsは": { "閾値":1.09}}} 、

答えて

0

スクリプト内の変数としてthresscoreを定義するとして、あなたがする必要はありません

if (score > thres)

if (${score} > ${thres})を置き換え、それらの値を取得するために ${}フォームを使用します
関連する問題