# Runtime Error on Terms Aggregation using Split Function

**URL:** <https://discuss.elastic.co/t/runtime-error-on-terms-aggregation-using-split-function/129967>\
**Category:** Elasticsearch\
**Created:** [April 29, 2018, 4:50pm UTC](https://discuss.elastic.co/t/runtime-error-on-terms-aggregation-using-split-function/129967 "2018-04-29T16:50:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Willian\_Fuks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/willian_fuks/32/30588_2.png) [@Willian\_Fuks](https://discuss.elastic.co/u/Willian_Fuks)\
**Post date:** [April 29, 2018, 4:50pm UTC](https://discuss.elastic.co/t/runtime-error-on-terms-aggregation-using-split-function/129967/1 "2018-04-29T16:50:50Z")

</div>

Hello,

I just asked for help at [SO](https://stackoverflow.com/questions/50082065/runtime-error-on-split-in-keyworded-field?noredirect=1#comment87183447_50082065) and decided to ask here as well.

I'm using a docker image ES 6.2.3 and a Python client to interact with ES.

Created a mapping for testing like so:

```
mapping = {
    'settings': {
        'number_of_shards': 1,
        'number_of_replicas': 0,
    },
    'mappings': {
        '_doc': {
            'properties': {
                'cat': {
                    'type': 'keyword',
                }
            }
        }
    }
}

```

Indexed some documets:

```
es.index('test_ind', '_doc', body={'cat': 'cat1,cat2,cat3'})
es.index('test_ind', '_doc', body={'cat': 'cat1,cat2,cat4'})

```

And tried running a terms aggregation by using a split operation on commas:

```
facet = {                                                                 
    "_source": ["cat"],
    "aggs": {
        "test": {
            "terms": {
                "script": {
                    "source": "doc['cat'].value.split(',')[0]",
                }
            }
        }
    }
}

r = es.search('test_ind', '_doc', body=facet)

```

But as it turns out, this error message raises:

> TransportError: TransportError(500, 'search\_phase\_execution\_exception', 'runtime error')

Looking at our logs for ES, just found this message in the docker image:

```
2018-04-29T06:20:39.871+0000: 137707.242: Total time for which application threads were stopped: 0.0077604 seconds, Stopping threads took: 0.0000672 seconds
2018-04-29T06:21:29.949+0000: 137757.320: [GC (Allocation Failure) 2018-04-29T06:21:29.949+0000: 137757.320: [ParNew
Desired survivor size 17432576 bytes, new threshold 6 (max 6)
- age 1: 4312504 bytes, 4312504 total
- age 2: 613880 bytes, 4926384 total
- age 3: 3088 bytes, 4929472 total
- age 4: 1536 bytes, 4931008 total
- age 5: 20752 bytes, 4951760 total
- age 6: 2576 bytes, 4954336 total
: 276935K->5314K(306688K), 0.0061500 secs] 757743K->486122K(1014528K), 0.0062660 secs] [Times: user=0.02 sys=0.00, real=0.00 secs] 

```

If I remove the `split` operation then it works normally. I wonder if anyone knows what can be causing this issue.

If you need any more info please let me know,

Thanks.

---

<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:** [May 27, 2018, 4:58pm UTC](https://discuss.elastic.co/t/runtime-error-on-terms-aggregation-using-split-function/129967/2 "2018-05-27T16:58:24Z")

</div>

Closed on May 27, 2018, 4:58pm UTC

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