# How to use split on script field on kibana

**URL:** <https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487>\
**Category:** Kibana\
**Created:** [November 6, 2017, 8:48am UTC](https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487 "2017-11-06T08:48:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xcl3721](https://avatars.discourse-cdn.com/v4/letter/x/c0e974/32.png) [@xcl3721](https://discuss.elastic.co/u/xcl3721)\
**Post date:** [November 6, 2017, 8:48am UTC](https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487/1 "2017-11-06T08:48:01Z")

</div>

hi.  
i wrote the painless script field on the kibana 5.6.1  
it's not work /&/.split(param)

how to use the split on script field on new version

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [November 6, 2017, 11:17pm UTC](https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487/2 "2017-11-06T23:17:03Z")

</div>

hi @xcl3721,

can you double check if you have enabled regex on your elasticsearch cluster? For more information, see here:

[https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-examples.html#modules-scripting-painless-regex](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-examples.html#modules-scripting-painless-regex)

If it isn't enabled, you'll likely get an error that's something like:

```auto
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["/\\&/.split(doc['foo'].val ...","^---- HERE"],"script":"/\\&/.split(doc['foo'].value)","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"foobar","node":"RHQOJfdSR2ODGBdyxOHtdQ","reason":{"type":"script_exception","reason":"compile error","script_stack":["/\\&/.split(doc['foo'].val ...","^---- HERE"],"script":"/\\&/.split(doc['foo'].value)","lang":"painless","caused_by":{"type":"illegal_state_exception","reason":"Regexes are disabled. Set [script.painless.regex.enabled] to [true] in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep recursion and long loops."}}}]},"status":500}

```

Also, you will need to escape that `&` if you try to match the actual character.

---

<div class="post-metadata">

**Author:** ![xcl3721](https://avatars.discourse-cdn.com/v4/letter/x/c0e974/32.png) [@xcl3721](https://discuss.elastic.co/u/xcl3721)\
**Post date:** [November 24, 2017, 5:09am UTC](https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487/3 "2017-11-24T05:09:16Z")

</div>

thank you sir，you are right

---

<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 22, 2017, 5:09am UTC](https://discuss.elastic.co/t/how-to-use-split-on-script-field-on-kibana/106487/4 "2017-12-22T05:09:29Z")

</div>

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