# Painless script. Illegal list shortcut value \[value\]. For try to stup field variable

**URL:** <https://discuss.elastic.co/t/painless-script-illegal-list-shortcut-value-value-for-try-to-stup-field-variable/194864>\
**Category:** Kibana\
**Created:** [August 12, 2019, 2:38pm UTC](https://discuss.elastic.co/t/painless-script-illegal-list-shortcut-value-value-for-try-to-stup-field-variable/194864 "2019-08-12T14:38:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nopma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nopma/32/46878_2.png) [@nopma](https://discuss.elastic.co/u/nopma)\
**Post date:** [August 12, 2019, 2:38pm UTC](https://discuss.elastic.co/t/painless-script-illegal-list-shortcut-value-value-for-try-to-stup-field-variable/194864/1 "2019-08-12T14:38:09Z")

</div>

Hello all,

I tried with Painless script to create a new field from another field.

I have this code

```
if(doc['name.keyword'].size()!=0){
      def p =/[^\/]+\/([^\/]+)/;
      def m = p.matcher(doc['name.keyword'].value);
       if (m.find()) {
        doc['test_name.keyword'].value = m.group(1);
        return m.group(1);
      }
}

```

If i use only the return is correct is show the correct text on the kibana but i want also to be on the \_doc

The error:

```
Caused by: java.lang.IllegalArgumentException: Illegal list shortcut value [value].
        at org.elasticsearch.painless.Def.lookupSetter(Def.java:443) ~[?:?]
        at org.elasticsearch.painless.DefBootstrap$PIC.lookup(DefBootstrap.java:156) ~[?:?]
        at org.elasticsearch.painless.DefBootstrap$PIC.fallback(DefBootstrap.java:208) ~[?:?]
        at org.elasticsearch.painless.PainlessScript$Script.execute(if(doc['name.keyword'].size()!=0){ ...:201) ~[?:?]
        at org.elasticsearch.search.fetch.subphase.ScriptFieldsFetchSubPhase.hitsExecute(ScriptFieldsFetchSubPhase.java:67) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:177) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.search.SearchService.lambda$executeFetchPhase$3(SearchService.java:540) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:380) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) ~[elasticsearch-7.1.1.jar:7.1.1]
```

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [August 13, 2019, 11:08pm UTC](https://discuss.elastic.co/t/painless-script-illegal-list-shortcut-value-value-for-try-to-stup-field-variable/194864/2 "2019-08-13T23:08:47Z")

</div>

I'm not sure if it's completely related but it seems you should be returning something in the case that the matcher does not match as well.

---

<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:** [September 10, 2019, 11:08pm UTC](https://discuss.elastic.co/t/painless-script-illegal-list-shortcut-value-value-for-try-to-stup-field-variable/194864/3 "2019-09-10T23:08:49Z")

</div>

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