Painless Compile error

HI, I am trying to get particular value from object array using painless but getting compile errors as below.

Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["GET bcbsm_search/Authorizatio ..."," ^---- HERE"],"script":"GET bcbsm_search/AuthorizationRequest/_search?pretty\n{\n "query": {\n "function_score": {\n "script_score": {\n "script": {\n "lang": "painless",\n "source": """\n string BillingNPI ="";\n for (int i = 0; i < doc['auth.providers'].length; ++i) {\n if(doc['auth.providers'][i].containsKey('Billing'))\n\t\t{\n\t\t\tBillingNPI = doc['auth.providers'][i].value;\n\t\t}\n }\n return BillingNPI;\n """\n }\n }\n }\n }\n}","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"bcbsm_search_v5","node":"4qlJkrGHReuZtyHdNbxHxA","reason":{"type":"script_exception","reason":"compile error","script_stack":["GET bcbsm_search/Authorizatio ..."," ^---- HERE"],"script":"GET bcbsm_search/AuthorizationRequest/_search?pretty\n{\n "query": {\n "function_score": {\n "script_score": {\n "script": {\n "lang": "painless",\n "source": """\n string BillingNPI ="";\n for (int i = 0; i < doc['auth.providers'].length; ++i) {\n if(doc['auth.providers'][i].containsKey('Billing'))\n\t\t{\n\t\t\tBillingNPI = doc['auth.providers'][i].value;\n\t\t}\n }\n return BillingNPI;\n """\n }\n }\n }\n }\n}","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"unexpected token ['bcbsm_search'] was expecting one of [{, ';'}]."}}}],"caused_by":{"type":"script_exception","reason":"compile error","script_stack":["GET bcbsm_search/Authorizatio ..."," ^---- HERE"],"script":"GET bcbsm_search/AuthorizationRequest/_search?pretty\n{\n "query": {\n "function_score": {\n "script_score": {\n "script": {\n "lang": "painless",\n "source": """\n string BillingNPI ="";\n for (int i = 0; i < doc['auth.providers'].length; ++i) {\n if(doc['auth.providers'][i].containsKey('Billing'))\n\t\t{\n\t\t\tBillingNPI = doc['auth.providers'][i].value;\n\t\t}\n }\n return BillingNPI;\n """\n }\n }\n }\n }\n}","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"unexpected token ['bcbsm_search'] was expecting one of [{, ';'}]."}}},"status":500}
at https://nlxesdev01.corp.cvscaremark.com:5601/bundles/kibana.bundle.js?v=14849:28:15872
at Function.Promise.try (https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:75:22403)
at https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:75:21773
at Array.map ()
at Function.Promise.map (https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:75:21728)
at callResponseHandlers (https://nlxesdev01.corp.cvscaremark.com:5601/bundles/kibana.bundle.js?v=14849:28:15484)
at https://nlxesdev01.corp.cvscaremark.com:5601/bundles/kibana.bundle.js?v=14849:28:3614
at processQueue (https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:38:23621)
at https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:38:23888
at Scope.$eval (https://nlxesdev01.corp.cvscaremark.com:5601/bundles/commons.bundle.js?v=14849:39:4619)

my script:

GET abc_search/req/_search?pretty
{
"query": {
"function_score": {
"script_score": {
"script": {
"lang": "painless",
"source": """
string BillingNPI ="";
for (int i = 0; i < doc['auth.providers'].length; ++i) {
if(doc['auth.providers'][i].roleType = 'Billing')
{
BillingNPI = doc['auth.providers'][i].novologixProvider.nPI;
}
}
return BillingNPI;
"""
}
}
}
}
}

Do you have any idea how to get rid of these errors

Got rid of this. Used painless script.

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