# Painless is a pain in my head

**URL:** <https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612>\
**Category:** Elasticsearch\
**Created:** [May 12, 2017, 6:46pm UTC](https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612 "2017-05-12T18:46:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvleandro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvleandro/32/14268_2.png) [@mvleandro](https://discuss.elastic.co/u/mvleandro)\
**Post date:** [May 12, 2017, 6:46pm UTC](https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612/1 "2017-05-12T18:46:22Z")

</div>

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](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](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](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](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](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](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](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](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](http://stg-cerberus.stone.com.br:5601/bundles/commons.bundle.js?v=14566:39:4619))

Can someone help me?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 12, 2017, 9:54pm UTC](https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612/2 "2017-05-12T21:54:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 9, 2017, 10:04pm UTC](https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612/3 "2017-06-09T22:04:11Z")

</div>

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