How to create a new script field to group values


(Vinay) #1

Dear All,

Am trying to create a new scripted field and need to group values. Please help me to write the script to get the values

if ( Status='Closed' or Status="Resolved' then 'Closed' else 'Pending').

How to write the same in Kibana script to create new field.

Regards,
Vinay N


(Larry Gregory) #2

Hi @vinay.rao,

You'll want something like this:

if (doc['status.keyword'].value == "Resolved" ||  doc['status.keyword'].value == "Closed") {
    return "Closed";
  }

return "Pending";

(Vinay) #3

@Larry_Gregory : Thanks a lot for your Workaround. I have used the Script which is suggested by you. But am not able to get the output field in my index. Please find the attachment of the error which am facing. Appreciate your response to find out the solution.

Regards,
Vinay N


(Larry Gregory) #4

Is result.state a keyword or text field? It should be a keyword field for this script to work correctly