# Is there any option to turn on groovy script in kibana?

**URL:** https://discuss.elastic.co/t/is-there-any-option-to-turn-on-groovy-script-in-kibana/58304
**Category:** Kibana
**Created:** [August 18, 2016, 2:10am UTC](https://discuss.elastic.co/t/is-there-any-option-to-turn-on-groovy-script-in-kibana/58304 "2016-08-18T02:10:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![daye\_Jeong](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@daye\_Jeong](https://discuss.elastic.co/u/daye_Jeong)
#### Post date: [August 18, 2016, 2:10am UTC](https://discuss.elastic.co/t/is-there-any-option-to-turn-on-groovy-script-in-kibana/58304/1 "2016-08-18T02:10:23Z")

</div>

First, sorry for my poor english.

**I want to use groovy script in kibana.(scripted field in index, or JSON input in visualization)**

My kibana version is 4.5.3

And my es setting like this:  
script.engine.groovy.indexed.aggs: true  
script.engine.groovy.inline.aggs: true  
script.engine.groovy.inline.mapping: true  
script.engine.groovy.inline.search: true  
script.engine.groovy.inline.update: true  
script.engine.groovy.inline.plugin: true  
script.inline: true  
script.indexed: true  
script.groovy.sandbox.enabled: true

and I use shield.

Anyway, I tried some script. ([Kibana Groovy Scripted Field for Aggregation: Visualize: Unsupported script value](https://discuss.elastic.co/t/kibana-groovy-scripted-field-for-aggregation-visualize-unsupported-script-value/54126/2))  
In the web page, It seems to able using groovy script in kibana.

1. kibana(4.5.3), add scripted field:  
doc['date'].date.dayOfWeek().get()+'\_'+doc['date'].date.dayOfWeek().getAsText()

when I clicked "discover" button, there was a error message like below.

Error: Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"lexer\_no\_viable\_alt\_exception","reason":"lexer\_no\_viable\_alt\_exception: null"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"\*\*\*\*\*","node":"g2yHBlh9R5K58NXUmNDNEw","reason":{"type":"script\_exception","reason":"Failed to compile inline script [doc['date'].date.dayOfWeek().get()+'_'+doc['date'].date.dayOfWeek().getAsText()] using lang [expression]","caused\_by":{"type":"script\_exception","reason":"Failed to parse expression: doc['date'].date.dayOfWeek().get()+'_'+doc['date'].date.dayOfWeek().getAsText()","caused\_by":{"type":"parse\_exception","reason":"parse\_exception: unexpected character '.g' on line (1) position (28)","caused\_by":{"type":"lexer\_no\_viable\_alt\_exception","reason":"lexer\_no\_viable\_alt\_exception: null"}}}}}]}}

1. In the visualization editor, tried this script as JSON Input  
{  
"script": "doc['date'].date.dayOfWeek().getAsText()",  
"lang" : "groovy",  
"valueType": "string"  
}

Error: Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"class\_cast\_exception","reason":"class\_cast\_exception: java.lang.String cannot be cast to java.lang.Number"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"\*\*\*\*\*\*","node":"g2yHBlh9R5K58NXUmNDNEw","reason":{"type":"class\_cast\_exception","reason":"class\_cast\_exception: java.lang.String cannot be cast to java.lang.Number"}}]}}

Is anyone have a same issue like me?

Is there any option to turn on groovy script?  
Can shield affect using script?

I really need some help...

---

<div class="post-metadata">

### Author: ![daye\_Jeong](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@daye\_Jeong](https://discuss.elastic.co/u/daye_Jeong)
#### Post date: [August 18, 2016, 5:59am UTC](https://discuss.elastic.co/t/is-there-any-option-to-turn-on-groovy-script-in-kibana/58304/2 "2016-08-18T05:59:45Z")

</div>

I want to use script on string field.. (not metric..)  
like "Total " + doc['somthing'].value

---

<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: [July 6, 2017, 1:40pm UTC](https://discuss.elastic.co/t/is-there-any-option-to-turn-on-groovy-script-in-kibana/58304/3 "2017-07-06T13:40:57Z")

</div>


