2016-09-08 5 views
0

나는 groovy를 처음 사용합니다. elasticsearch 감시자 조건에서 사용되는 간단한 프로그램을 작성했지만 로그 문 뒤에 MissingMethodException 예외가 발생합니다.탄성 검색을 사용한 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}) 교체 그 값을 얻을 수 ${} 양식을 사용
관련 문제