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

Hello all,

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

I have this code

      def p =/[^\/]+\/([^\/]+)/;
      def m = p.matcher(doc['name.keyword'].value);
       if (m.find()) {
        doc['test_name.keyword'].value =;

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( ~[?:?]
        at org.elasticsearch.painless.DefBootstrap$PIC.lookup( ~[?:?]
        at org.elasticsearch.painless.DefBootstrap$PIC.fallback( ~[?:?]
        at org.elasticsearch.painless.PainlessScript$Script.execute(if(doc['name.keyword'].size()!=0){ ...:201) ~[?:?]
        at ~[elasticsearch-7.1.1.jar:7.1.1]
        at ~[elasticsearch-7.1.1.jar:7.1.1]
        at$executeFetchPhase$3( ~[elasticsearch-7.1.1.jar:7.1.1]
        at$3.doRun( ~[elasticsearch-7.1.1.jar:7.1.1]
        at ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun( ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun( ~[elasticsearch-7.1.1.jar:7.1.1]

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.

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