Support Questions

Find answers, ask questions, and share your expertise

How to apply a condition on a map of a nested list using RecordPath language in UpdateRecord in Nifi

avatar
New Contributor

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"

 

2 REPLIES 2

avatar
Community Manager

@nidhipal Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our NiFi experts @SAMSAL @joseomjr  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
New Contributor

Hi @nidhipal 

Looks like you figured this out here, https://community.cloudera.com/t5/Support-Questions/Possible-RecordPath-to-fetch-data-from-a-list-ba...

The added RecordPath works.
 ../goodIdentifications[*][./goodIdentificationTypeId = "SKU"]/idValue

Thank you!