Painless: dynamic variables in hash

hello,

i want to get a ctx.payload like this :

"transform": {
   "script": {
      "source": "ctx.payload.transform = [ ]; def text = [ 'test1' : \"{{ctx.payload.hits.total}}\" ]; ctx.payload.transform.add(text); return ctx.payload.transform;",
      "lang": "painless"
   }
},

But the value of {{ctx.payload.hits.total}} is not affected to 'test1' but it affect the string.

How can i pass the value ?

I find the solution, i write it like that : ctx['payload']['hits']['total']

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