# Failing scripted field in Elastic 7.4.2

**URL:** <https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503>\
**Category:** Elasticsearch\
**Created:** [November 5, 2019, 1:33am UTC](https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503 "2019-11-05T01:33:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShaneLillie\_RAD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanelillie_rad/32/57131_2.png) [@ShaneLillie\_RAD](https://discuss.elastic.co/u/ShaneLillie_RAD)\
**Post date:** [November 5, 2019, 1:33am UTC](https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503/1 "2019-11-05T01:33:20Z")

</div>

Hi, I have the following Painless scripted field in Kibana:

```
return doc['a'].size() != 0 && doc['b'].size() != 0 && doc['a'].value == doc['b'].value;

```

And I'm not sure why but that is giving me the following error:

> No field found for [a] in mapping with types

I've also tried the following:

```
return doc.containsKey('a') && doc.containsKey('b') && doc['a'].value == doc['b'].value;

```

which gives me the following error:

> A document doesn't have a value for a field! Use doc[].size()==0 to check if a document is missing a field!

I have seen conflicting answers for how to verify that a field exists before using it and it seems like .size() != 0 is the correct approach, but if that is true then I'm very confused about why I'm receiving the error that I am from that. Is there anything else that I might be doing wrong here?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 5, 2019, 10:04am UTC](https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503/2 "2019-11-05T10:04:12Z")

</div>

Have you tried using what is mentioned in the message?

```auto
return doc['a.keyword'].size() > 0 && doc['b.keyword'].size() > 0 && doc['a.keyword'].value == doc['b.keyword'].value

```

---

<div class="post-metadata">

**Author:** ![ShaneLillie\_RAD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanelillie_rad/32/57131_2.png) [@ShaneLillie\_RAD](https://discuss.elastic.co/u/ShaneLillie_RAD)\
**Post date:** [November 5, 2019, 4:40pm UTC](https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503/3 "2019-11-05T16:40:02Z")

</div>

Oh, sorry, yeah all of the map indexes do match up in this case.

We're also currently using filebeat 6.3 and when we try and do the update to 6.7 in order to then upgrade to the latest version, we get this error a lot more on scripted fields that were otherwise working fine.

---

<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:** [December 3, 2019, 4:40pm UTC](https://discuss.elastic.co/t/failing-scripted-field-in-elastic-7-4-2/206503/4 "2019-12-03T16:40:13Z")

</div>

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