Painless script failing whenever you fetch a field from doc

Hi,
I am trying out ‘Painless’ scripts on Kibana (by creating scripted fields https://www.elastic.co/guide/en/kibana/current/scripted-fields.html). My script runs just fine until I access a field from “doc” object. I immediately get following Warning on Kibana UI:

Warning

Courier Fetch: 1 of 2 shards failed.

For some reason, line 6 of my script cause the warning and no logs are displayed on UI. If I remove this line(along with braces), it works just fine:

String featureName="pendingApp";
String key="customerFeatures.0.featureId";

if(doc.containsKey(key))
{
if(doc[key]=='yes')
{
return "AA";
}
}
return "N/A";

On Kibana, following is how actually the logs appear (you can see the field 'customerFeatures.0.featureId' is available):

41%20AM

Do I need to enable something on Kibana, or change the indexing somehow?

I will really appreciate any help,

Thanks

Hello,

What are you trying to accomplish with the scripted field?
If you are looking for the customerFeatures.0.featureId field to have the value yes you need to use doc[key].value == "yes"

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