Condition doesn't trigger even if true


I'm making a watcher that should alert if some value is null. So I get several hits and for each hit I check whether the result is empty. When I do a search query I can see that there are such results but my condition keeps returning false. I'm not sure if I've written the script wrong or if all of the hits have to pass in order to get a final true and trigger the condition? This is how my script looks:

"script": {
"lang": "painless",
"source": "for(def hit: ctx.payload.hits.hits) {
if(hit._source.result.value == null) { return true; }
} return false; "

I have tried to move the "return false" to after the if-statement and tried with an else but it gives me an error..

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.