Scripted Fields - Script is invalid


I'm not a developer, so I'm not familiar with program language.
I added several scripted fields.
I tried to add a new scripted field, but I can't.
"Script is invalid."
Following is an err.

How can I solve this problem?
Some documents don't have the peak(original field) value, just null (-).
Please, let me know how can I edit my script.

Thank you so much!

The reason property to the bottom of your screenshot is a good description of the problem. You are trying to access the peak field, but not all documents in your index have that field.

You should be able to fix your script by adding

if (doc['peak'].size() == 0) { return null; }

to the top

Thank you so much!! It works!

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