# Scripted field conditionals failing (5 of 15 shards failed)

**URL:** <https://discuss.elastic.co/t/scripted-field-conditionals-failing-5-of-15-shards-failed/147807>\
**Category:** Kibana\
**Created:** [September 8, 2018, 11:04am UTC](https://discuss.elastic.co/t/scripted-field-conditionals-failing-5-of-15-shards-failed/147807 "2018-09-08T11:04:05Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![caub](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/caub/32/33783_2.png) [@caub](https://discuss.elastic.co/u/caub)\
**Post date:** [September 11, 2018, 5:30pm UTC](https://discuss.elastic.co/t/scripted-field-conditionals-failing-5-of-15-shards-failed/147807/3 "2018-09-11T17:30:12Z")

</div>

Ok thanks @Joe_Fleming, you were right on checking for the value, I found [another thread explaining it](https://discuss.elastic.co/t/fields-aggregation-or-field-formatter/87023/2)

Now the issue is that my scripted fields have empty values, even though the doc fields are not empty

Scripted field 1: **\_msg** painless String

```auto
if (doc.err_msg.value != null)
  return doc.err_msg.value + '--' + doc.err_stack.value;
return '';

```

Scripted field 2: **\_req** painless String

```auto
if (doc['req.path'].value != null)
  return doc['req.method'].value +' '+ doc['req.path'].value +' '+ doc['res.status'].value;
return '';

```

 ![2018-09-11-192221_1626x953_scrot](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5d360595b9028e5e2fb49918e2e5cf715e537748.png)

^ You can see above `doc['req.path']`, `doc['req.method']` are not empty

We would think`doc['req.path'].value != null` is evaluated to false, but if I change the script to just:

```auto
return doc['req.method'].value +' '+ doc['req.path'].value +' '+ doc['res.status'].value;

```

it's still the same

* * *

**note** I took care to refresh the kibana filebeat- index after editing those fields

**note: on the 5 of 15 shards failed error**  
the error with shards I has before, is probably due to err\_stack being a Text, and not a Keyword

I had force those types preconfigured in my filebeat.yml config:

```auto
setup.template.append_fields:
  - name: err_msg
    type: keyword
  - name: err_stack
    type: text

```

But I removed this, it's not necessary as kibana will take string type by default, which works

---

_[View the full topic](https://discuss.elastic.co/t/scripted-field-conditionals-failing-5-of-15-shards-failed/147807)._
