Keep getting null in field scripting

Hi, not all documents has the field "seconds", so I check for it, and then check if the value is not null, but I keep getting null results,

if (doc.containsKey('seconds')){
    if (doc['seconds'].value != null){
        return doc['seconds'].value;
    }
}

Any clues on what is happening?

the field is a number
return type number
elk 7.51

The return type is number only when the if is true.

To me, it looks like the script needs another return and the end, and provide a fallback when the value is null.

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