Painless - Getting Field with whitespace Character

I have a field with Whitespace character: i.e 'Error Message.keyword'

How can I get this field with painless?

1 ) ctx.payload.buckets[0].'Error Message.keyword'
2 ) def error='Error Message.keyword'; ctx.payload.buckets[0].error

Both above versions do not work.

You need to use brackets to access a key from a map.

ctx.payload.buckets[0]['Error Message.keyword']

Worked!

Why do I get "[]? How can I get rid of []?

      "payload": {
        "error": "[no user found]"
      }

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