Hi all,
I’m working on an Elasticsearch Watcher that has multiple search inputs. What I want to do is:
-
Run the first input query.
-
If this query returns more than 0 hits, I want to skip running the other inputs entirely and go straight to evaluating the condition and actions.
Basically, I’m looking for a way to short-circuit the inputs so that if one already satisfies a condition (like hits > 0), the other queries don’t run at all.
Is there a way to achieve this in Elasticsearch Watcher? If not directly, what would be the best workaround?
Thanks in advance!
Hi @Simriti_Bundhoo
Interesting use-case.
So as per understanding you are using chain input which will have multiple inputs?
InputA > 0
InputB > 2
InputC > Ignore execution
InputD > Ignore execution
InputE > Ignore execution
move to condition > action part
As per the documentation i do not think we can skip this at input level, this will have to be evaluated at condition level using transform.
Why you want to short-circuit , these inputs are taking more time to execute ?
What if 2 inputs have hits > 0 ?
Thanks!!
Hello, yes, my goal is to save time by avoiding unnecessary executions. In the example you gave, I am only interested in whether InputB has hits > 0. Once that condition is met, I want to move immediately to the condition/action part.
If InputB meets the criteria, I am not concerned with the results of Input A, C, D, or E; there Is no need to process the rest.
I guess since it is not possible to skip, then I do not really have a choice haha. Thanks!
1 Like