Convert Number to String Kibana JSON Input

Hello,

I am trying to use translate in the JSON INPUT to convert ItemValue 0 to Test/String Healthy

I have been trying to use painless in the JSON Input but for some reason it doesnt work.
Not too familiar with Painless so want some help here on how I can show Healthy for 0 value in the visualizer.

I am hoping I dont have to create a scripted field and do it on the visulalizer.

{
"script": {
"inline": if (doc['ItemValue'].value == 0) { return "Healthy"; } return "",
"lang": "painless"
}
}

Is there something I am missing do I need to use .getAsText in the script.

Thanks again for the help in advance

Using an inline script you can't cast a value from a number to a string unfortunately. You should use the scripted field for that

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