Getting empty value in script field in Kibana 5.2.1


I am using Kibana 5.2.1 scripted field. I wrote one painless script as follows but I am not getting the return value on the created script field. Always I am getting empty value in my script field. I am not sure where I am going wrong.

if (doc['msg_sent.keyword'].value == "1" ){ 
   return  "Very Dissatisfied";
if (doc['user_msg_sent.keyword'].value == "2" ){ 
    return   "Dissatisfied";

Any help is highly appreciable. Thanks in advance.

A couple of things to check;

  1. Are you sure you have those msg_sent.keyword and user_msg_sent.keyword fields

  2. And that those fields are of type string

  3. And that those fields are Searchable and Aggregatable

  4. Then also note that if you open Discover in one browser tab, and the scripted fields Management page in another tab, when you make a change to the scripted field, you have to refresh your Discover browser tab to get any changes you make to the scripted field to take affect.

  5. Make sure you set the Type of the scripted field to String. This needs to match the return type and not the type of the values you are checking (which should both be strings in your case).

I assume you're not getting any error messages in Discover when you refresh the tab?

Please let us know if any of this helped.


Those fileds are not aggregatable ? Do we need to make this field aggregable?

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