Contains() function in Scripted field of Kibana

Hi,

I am trying to create a scripted field(Painless) based on the if condition on the present Field.
The criteria is if a field(suppose "Name") contains "sammy" as a value.

I want to check if the value contains "am" as a substring so it can enter the if condition.
Just like IndexOf, i tried using contains function of java.
I tried to using it, although it does not return any error it still gives empty values.

Eg:-
if(doc['Name'].value.contains("am")){
return "success"
}

1 Like

For me this script works. I have set up the mapping for the index it is running against so that the Name field is mapped as a keyword type. Maybe you have no values that contain "am"? If you want no empty values for this field, you should add an else.

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