# Error message splitting series by scripted field terms agg

**URL:** <https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264>\
**Category:** Kibana\
**Created:** [September 20, 2020, 4:46pm UTC](https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264 "2020-09-20T16:46:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiclasK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niclask/32/47189_2.png) [@NiclasK](https://discuss.elastic.co/u/NiclasK)\
**Post date:** [September 20, 2020, 4:46pm UTC](https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264/1 "2020-09-20T16:46:24Z")

</div>

Hi,

I added one scripted field. It adds a Category string field based on an existing string field.

When I try to split series using terms agg and the scripted field in a bar visualization I get the following error message:  
"[esaggs] \> Not Found"  
When I click on "See the full error" I get the same text.

I'm using Elasticsearch and Kibana 7.9.1.

---

<div class="post-metadata">

**Author:** ![NiclasK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niclask/32/47189_2.png) [@NiclasK](https://discuss.elastic.co/u/NiclasK)\
**Post date:** [September 20, 2020, 8:51pm UTC](https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264/2 "2020-09-20T20:51:31Z")

</div>

So what I think is going on is that I get an exception in my scripted field.

---

<div class="post-metadata">

**Author:** ![NiclasK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niclask/32/47189_2.png) [@NiclasK](https://discuss.elastic.co/u/NiclasK)\
**Post date:** [September 20, 2020, 9:15pm UTC](https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264/3 "2020-09-20T21:15:10Z")

</div>

The problem was that the existing field my script used, had null values in some documents.  
I added a check to handle this:

```
if (doc[fieldKey].size() != 0)
{
}
```

---

<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:** [October 18, 2020, 9:15pm UTC](https://discuss.elastic.co/t/error-message-splitting-series-by-scripted-field-terms-agg/249264/4 "2020-10-18T21:15:17Z")

</div>

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