nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leandro Lourenço <leandrohlsi...@gmail.com>
Subject Help on NiFi RecordPath
Date Fri, 09 Feb 2018 00:29:16 GMT
Hey there,

I've been trying to use RecordPath to retrieve information, but I'm a bit
stuck.
Have a complex schema that involves records and maps.

This is my Avro Schema:
{
  "type": "record",
  "name": "Contact",
  "fields" : [
    {"name": "id", "type": "string"},
    {"name": "firstName", "type": "string"},
    {"name": "lastName", "type": "string"},
    {"name": "fullName", "type": "string"},
    {
    "name" : "attachments",
    "type" : {
      "type" : "record",
      "name" : "attachments",
      "fields" : [ {
        "name" : "keys",
        "type" : {
          "type" : "array",
          "items" : "string"
        },
      }, {
        "name" : "values",
        "type" : {
          "type" : "map",
          "name" : "attachments",
          "namespace" : "values",
          "values": {
              "type" : "record",
              "name": "attachments",
              "namespace": "attachment",
              "fields": [
                {"name": "id", "type": "string"},
                {"name": "value", "type": "string"},
                {"name": "filename", "type": "string"},
                {"name": "type", "type": "string"},
                {"name": "base64", "type": "string"}
              ]
            }
        },
      } ]
    }
  }
  ]
}

Here's an input example:
{
    "id" : "1234",
    "firstName" : "Leandro",
    "lastName" : "Silva",
    "fullName" : "Leandro Silva",
    "attachments" : {
        "values" : {
            "68e0ccf7-a021-4797-b9be-48d4eab0f2db" : {
                "id" : "68e0ccf7-a021-4797-b9be-48d4eab0f2db",
                "value" : "https://example.com/file.pdf",
                "filename" : "file.pdf",
                "type" : "pdf"
            }
        },
        "keys" : [
            "68e0ccf7-a021-4797-b9be-48d4eab0f2db"
        ]
    }
}

And I'm trying to get the property *value* inside attachments.
I've tried the following:
/attachments/values['68e0ccf7-a021-4797-b9be-48d4eab0f2db']/value (which
works)
However I need to get all URLs inside this record and the keys are not
static.

Tried /attachments/values[]/value (but doesn't work. Unexpected token ']')
//value (doesn't work, most probably because there's a map in between)
/attachments/values/*/value (doesn't work)
/attachments/values//value (doesn't work)

The second step would be to write back to a new property inside this same
structure, but I am a bit far from there.

Any ideas? All help is very much appreciated.

Thank you.

Leandro Lourenco

Mime
View raw message