No data found error when added new scripted field


I have a question regarding scripted filed in index patterns. My log stash event one of the column name is "model.size" and it's value is like "69147 Bytes". I am trying to convert this value into MBs. So I added a script in index pattern scripted field. When I tried to get my data nothing is populated, if I remove this script data is getting populated. I did not understand what is wrong with my script?

My script is:-

Name: Size_MB
Language: painless
Type: String
Format: default
if(doc['model.size'].value !=null) {
return doc['model.size'].value / 1024 +'MB';
return "";

Please guide me if any thing wrong in the process or if any other way is there let me know.

Thanks in advance..!!

It sounds like you are trying to display the value in MB. If that is the case, then setup a field formatter for the field instead of using a scripted field. That way the value will be displayed in MB but there will be no performance penalty for using a scripted field.

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