How to return multiline or long list of values in painless?

hi,
I've quite a large set of key-value fields to return in the transform as below. But I wanted it to look clean and copy-paste friendly, but fails (if I put all into one line it works)

    "index_alert": {
      "transform": {
        "script": {
          "source": """
                        return [
                                     'watch_id': ctx.watch_id, 
                                     'execution_time': ctx.execution_time,
                                     'another_key1': ctx.another_val1,
                                     'another_key2': ctx.another_val2,
                                     'another_key3': ctx.another_val3
                     ]
                    """,
          "lang": "painless"
        }
      },

But instead if I had put into a long list, it works as below !

"source": """return ['watch_id': ctx.watch_id,'execution_time': ctx.execution_time,'another_key1': ctx.another_val1,'another_key2': ctx.another_val2,'another_key3': ctx.another_val3]"""

Any idea how to pass multi-line return array?

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