Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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

avatar
Frequent Visitor

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,
Senior 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
Frequent Visitor

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!