Question
How to apply a condition on a map of a nested list using RecordPath language in UpdateRecord in Nifi
The feed json is like below:
[
{
"orderId": "10000",
"orderItems": [
{
"orderItemSeqId": "10001",
"productIdentifications": [
{
"productIdentificationTypeId": "SKU",
"idValue": "98706"
},
{
"productIdentificationTypeId": "UPCA",
"idValue": "98788"
},
{
"productIdentificationTypeId": "HS_CODE",
"idValue": "98790"
}
]
},
{
"orderItemSeqId": "10002",
"productIdentifications": [
{
"productIdentificationTypeId": "SKU",
"idValue": "98690"
},
{
"productIdentificationTypeId": "UPCA",
"idValue": "98698"
},
{
"productIdentificationTypeId": "HS_CODE",
"idValue": "98999"
}
]
}
]
}
]Requirement- Prepare two new fields for each item of an order.
1. Style: idValue of productIdentification whose productIdentificationTypeId is SKU.
2. UPC: idValue of productIdentification whose productIdentificationTypeId is UPCA.
The output json should be
[
{
"orderId": "10000",
"orderItems": [
{
"orderItemSeqId": "10001",
"productIdentifications": [
{
"productIdentificationTypeId": "SKU",
"idValue": "98706"
},
{
"productIdentificationTypeId": "UPCA",
"idValue": "98788"
},
{
"productIdentificationTypeId": "HS_CODE",
"idValue": "98790"
}
],
"Style": "98706",
"UPC": "98788"
},
{
"orderItemSeqId": "10002",
"productIdentifications": [
{
"productIdentificationTypeId": "SKU",
"idValue": "98690"
},
{
"productIdentificationTypeId": "UPCA",
"idValue": "98698"
},
{
"productIdentificationTypeId": "HS_CODE",
"idValue": "98999"
}
],
"Style": "98690",
"UPC": "98698"
}
]
}
]
Tried this property in UpdateRecord using RecordPath language but it didn't work.
name: "/orderItems[*]/Style"
value: "/orderItems[*]/goodIdentifications[./goodIdentificationTypeId='SKU']/idValue"

