How to create a scripted field with multiple conditions

HI,

I have created a scripted field sc1 in kibana like;

doc['error.keyword'].value == 'error1' ? 0 : 1

this makes sc1 0 if the content is error1 and 0 if content is not error1. What I want is, I want sc1 to be 0, if the content is either error1 or error2. How can I do this?

Thanks in advance..

@elasticcloud Painless supports the || (OR) operator you can use to do the following:

doc['error.keyword'].value == 'error1' || doc['error.keyword'].value == 'error2' ? 0 : 1

Or you can use the contains method to do the following:

['error1', 'error2'].contains(doc['error.keyword'].value) ? 0 : 1

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