Thank you Mark, it worked!

Now the next question:
how to write to these sub records a distinct value per record found?
I'm using /attachments/values[*]/base64 as Result RecordPath, however it
doesn't seem right.
If one value is found, it gets written to all sub records.
And if more than one value is found (from the query you helped me build),
then nothing is set.

Hoping this is easy to fix, just like the previous obstacle.

Thank you!

Leandro Lourenco

On Fri, Feb 9, 2018 at 12:35 AM, Mark Payne <marka...@hotmail.com> wrote:

> Leandro,
>
> I think you’re super close! You should be able to use:
>
> /attachments/values[*]/value
>
> Sent from my iPhone
>
> On Feb 8, 2018, at 7:29 PM, Leandro Lourenço <leandrohlsi...@gmail.com>
> wrote:
>
> 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
>
>

Reply via email to