How to use AND operator in Kibana scripted field

Hi,

I am trying to use && operator in Kibana scripted field but it's not working. I am using following painless code.

def diff = new Date().getTime() - doc['OpenTime'].value;
def daysdiff = diff / 1000 / 60 / 60 / 24;

if (daysdiff >= 6) && (daysdiff <= 10) {
return "6 To 10 Days"
} else {
return "10+ Days"
}

One thing more, is it possible to use if elseif else in painless? If yes, how?

it should be possible to use if/ else if/ else .... if not straight forward, with nesting if statements.

the and should also work, but your if syntax seems to be wrong

if (CONDITION1 && CONDITION2), not if (COND1) && (COND2) (mind the parenthesis)

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