Painless is a pain in my head

Hello everyone!

I am trying to start to use the painless language.

I created a String field with just de follow code:

if (true) {
    return 'R$ XX,xx' + doc['AdditionalData.ResponseMessage.AmountAuthorized'].value;
}

It don't works. When i put if statement crashes with the follow exception:

Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["if (true) { return 'R$ XX ...","^---- HERE"],"script":"if (true) { return 'R$ XX,xx' + doc['AdditionalData.ResponseMessage.AmountAuthorized'].value; }","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"buy4-authorizationprovider-2017.05.12","node":"8lWOf-9KROa5e_csz1ufPw","reason":{"type":"script_exception","reason":"compile error","caused_by":{"type":"illegal_argument_exception","reason":"Extraneous if statement."},"script_stack":["if (true) { return 'R$ XX ...","^---- HERE"],"script":"if (true) { return 'R$ XX,xx' + doc['AdditionalData.ResponseMessage.AmountAuthorized'].value; }","lang":"painless"}}],"caused_by":{"type":"script_exception","reason":"compile error","caused_by":{"type":"illegal_argument_exception","reason":"Extraneous if statement."},"script_stack":["if (true) { return 'R$ XX ...","^---- HERE"],"script":"if (true) { return 'R$ XX,xx' + doc['AdditionalData.ResponseMessage.AmountAuthorized'].value; }","lang":"painless"}},"status":500}
at http://stg-cerberus.stone.com.br:5601/bundles/kibana.bundle.js?v=14566:26:31375
at Function.Promise.try (http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:75:22354)
at http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:75:21724
at Array.map (native)
at Function.Promise.map (http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:75:21679)
at callResponseHandlers (http://stg-cerberus.stone.com.br:5601/bundles/kibana.bundle.js?v=14566:26:30987)
at http://stg-cerberus.stone.com.br:5601/bundles/kibana.bundle.js?v=14566:26:19562
at processQueue (http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:38:23621)
at http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:38:23888
at Scope.$eval (http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:39:4619)

Can someone help me?

I believe it's telling you that if(true) is useless so you must remove it.

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