0

I'm looking for a way to extract the contents of an object such as

{
    "mdc":{
      "key1": "value1",
      "key2": "value2",
      ...
    }
}

and transform that into

{
       "key1": "value1",
       "key2": "value2",
       ...
        "mdc":{
          "key1": "value1",
          "key2": "value2"
        }
}

I was looking at the provided processors but couldn't find anything useful.

My initial thought was to:

  • specify a field whose contents I can regex match or select in such another way
  • iterate over them
  • inline the their contents to new fields.

Any suggestions would be greatly appreciated!

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
zaxme
  • 1,065
  • 11
  • 29

1 Answers1

0

It wasn't that hard after all.

   {
      "mdcflatten": {
        "processors": [
          {
            "script": {
              "lang": "painless",
              "inline": " ctx.mdc.keySet().each (key -> ctx[key] = ctx.mdc.get(key))"
            }
          },
          {
            "remove": {
              "field": "mdc"
            }
          }
        ]
      }

Hope this helps.

zaxme
  • 1,065
  • 11
  • 29