Upgrade to 7.2 causes shards failed due to painless script error

Could anyone with more knowledge of painless could help me with a problem I have right now:
After upgrading Stack to 7.2, in one of the visualization that is using Scripted field, I get shards failed error, it used to work before upgrade.

the painless code that used to work in 6.5:

if (!doc.containsKey('data.AudioPath.keyword') || doc['data.AudioPath.keyword'].value == null){ return ""; } return "https://xxx/" + doc['data.AudioPath.keyword'].value;

and verified that data is correctly passed as type String:

"_source" : {
      "data" : {
        ...
        "AudioPath" : "08035264-9d60-11e9-a23a-8c0f6f7c1ae2.wav"
      },

Here's the message in POST response:

script_stack: ["org.elasticsearch.index.fielddata.ScriptDocValues$Strings.get(ScriptDocValues.java:496)",…]
2: "if (!doc.containsKey('data.AudioPath.keyword') || doc['data.AudioPath.keyword'].value == null){ "
3: "                                                                               ^---- HERE"

and also:

caused_by: {type: "illegal_state_exception",…}
reason: "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"

I went through documentation before upgrade and nowhere I found any statement of breaking changes in Painless Language...

resolved using doc['data.AudioPath.keyword'].empty

I don't think it's documented as a breaking change anywhere.

Hey,

it is mentioned here: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#_accessing_missing_document_values_will_throw_an_error

Also, if you upgrade to 6.8 before going to 7 there should have been a log message in the depreciation log (one of the reasons why it makes sense to get to the latest 6.x release first).

Is there anything we could have done to improve the docs regarding your issue? If so, happy to hear!

Hope this helps.

--Alex

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