Failing scripted field in Elastic 7.4.2

Hi, I have the following Painless scripted field in Kibana:

return doc['a'].size() != 0 && doc['b'].size() != 0 && doc['a'].value == doc['b'].value;

And I'm not sure why but that is giving me the following error:

No field found for [a] in mapping with types

I've also tried the following:

return doc.containsKey('a') && doc.containsKey('b') && doc['a'].value == doc['b'].value;

which gives me the following error:

A document doesn't have a value for a field! Use doc[].size()==0 to check if a document is missing a field!

I have seen conflicting answers for how to verify that a field exists before using it and it seems like .size() != 0 is the correct approach, but if that is true then I'm very confused about why I'm receiving the error that I am from that. Is there anything else that I might be doing wrong here?

Have you tried using what is mentioned in the message?

return doc['a.keyword'].size() > 0 && doc['b.keyword'].size() > 0 && doc['a.keyword'].value == doc['b.keyword'].value

Oh, sorry, yeah all of the map indexes do match up in this case.

We're also currently using filebeat 6.3 and when we try and do the update to 6.7 in order to then upgrade to the latest version, we get this error a lot more on scripted fields that were otherwise working fine.

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