<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Get only element based on a single parameter in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354555#M236935</link>
    <description>&lt;P&gt;Thanks for the update, however that's is the problem.&lt;/P&gt;&lt;P&gt;The Query Record does not fit my needs cause cannot implement the logic.&lt;/P&gt;&lt;P&gt;Note that the json doesn't have always all situation codes, so the pseudo code should be:&lt;/P&gt;&lt;P&gt;Grab the element with sit_code = POD only if present, otherwise go further with others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciate.&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 15:22:46 GMT</pubDate>
    <dc:creator>Ray82</dc:creator>
    <dc:date>2022-10-11T15:22:46Z</dc:date>
    <item>
      <title>Get only element based on a single parameter</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354547#M236931</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;hope anyone can point me on the right direction.&lt;/P&gt;&lt;P&gt;I have the following flow file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[ {
  "version" : "5",
  "type" : "REPORT",
  "dp_code" : "DHA592",
  "field4" : "83482227299911",
  "field5" : "83482227299911",
  "platform_name" : "GHESTEM LA CHAPELLE",
  "field7" : "01143200",
  "field8" : "72801371220938",
  "field9" : "72801371220938",
  "carrier_name" : "",
  "shipper_name" : "",
  "field12" : "",
  "consignee_name" : "",
  "consignee_code" : "",
  "consignee_address" : "",
  "consignee_city" : "",
  "field17" : "",
  "ldc_number" : "",
  "ldc_date" : "",
  "shipment_number" : "2022115144",
  "shipment_code" : "2022115144/SH",
  "field22" : "",
  "field23" : "",
  "field24" : "",
  "field25" : "liv.cfm",
  "situation_code" : "LIV",
  "justification_code" : "CFM",
  "situation_date" : "20221003",
  "feedback_date" : "202210061222",
  "anomaly_packages_number" : "",
  "comments" : "",
  "new_appointment_date" : "",
  "field33" : "",
  "field34" : "",
  "field35" : "",
  "assigned" : "",
  "field37" : "",
  "agreed_tax" : "",
  "field39" : "",
  "field40" : "20221006123304-3f621cf7-3",
  "field41" : "",
  "field42" : "",
  "field43" : "",
  "field44" : "212059",
  "doc_url" : "",
  "field46" : "",
  "field47" : "",
  "field48" : ""
}, {
  "version" : "5",
  "type" : "REPORT",
  "dp_code" : "DHA592",
  "field4" : "83482227299911",
  "field5" : "83482227299911",
  "platform_name" : "GHESTEM LA CHAPELLE",
  "field7" : "01143200",
  "field8" : "72801371220938",
  "field9" : "72801371220938",
  "carrier_name" : "",
  "shipper_name" : "",
  "field12" : "",
  "consignee_name" : "",
  "consignee_code" : "",
  "consignee_address" : "",
  "consignee_city" : "",
  "field17" : "",
  "ldc_number" : "",
  "ldc_date" : "",
  "shipment_number" : "2022115144",
  "shipment_code" : "2022115144/SH",
  "field22" : "",
  "field23" : "",
  "field24" : "",
  "field25" : "",
  "situation_code" : "POD",
  "justification_code" : "CFM",
  "situation_date" : "20221003",
  "feedback_date" : "202210061208",
  "anomaly_packages_number" : "",
  "comments" : "",
  "new_appointment_date" : "",
  "field33" : "",
  "field34" : "",
  "field35" : "",
  "assigned" : "",
  "field37" : "",
  "agreed_tax" : "",
  "field39" : "",
  "field40" : "20221006121304-3f61f8b6-3",
  "field41" : "",
  "field42" : "",
  "field43" : "",
  "field44" : "212059",
  "doc_url" : "",
  "field46" : "",
  "field47" : "",
  "field48" : "S"
}, {
  "version" : "5",
  "type" : "REPORT",
  "dp_code" : "DHA592",
  "field4" : "83482227299911",
  "field5" : "83482227299911",
  "platform_name" : "GHESTEM LA CHAPELLE",
  "field7" : "01143200",
  "field8" : "72801371220938",
  "field9" : "72801371220938",
  "carrier_name" : "",
  "shipper_name" : "",
  "field12" : "",
  "consignee_name" : "",
  "consignee_code" : "",
  "consignee_address" : "",
  "consignee_city" : "",
  "field17" : "",
  "ldc_number" : "",
  "ldc_date" : "",
  "shipment_number" : "2022115144",
  "shipment_code" : "2022115144/SH",
  "field22" : "",
  "field23" : "",
  "field24" : "",
  "field25" : "",
  "situation_code" : "AAR",
  "justification_code" : "CFM",
  "situation_date" : "20221003",
  "feedback_date" : "202210061208",
  "anomaly_packages_number" : "",
  "comments" : "",
  "new_appointment_date" : "",
  "field33" : "",
  "field34" : "",
  "field35" : "",
  "assigned" : "",
  "field37" : "",
  "agreed_tax" : "",
  "field39" : "",
  "field40" : "20221006121304-3f61f8b6-3",
  "field41" : "",
  "field42" : "",
  "field43" : "",
  "field44" : "212059",
  "doc_url" : "",
  "field46" : "",
  "field47" : "",
  "field48" : "S"
} ]&lt;/LI-CODE&gt;&lt;P&gt;My need is to grab only one element of json file based on "situation_code" in a priority order.&lt;/P&gt;&lt;P&gt;To explain me well, situation code can have the following possible values:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;POD (search priority 1)&lt;/LI&gt;&lt;LI&gt;LIV (search priority 2)&lt;/LI&gt;&lt;LI&gt;AAR (search priority 3)&lt;/LI&gt;&lt;LI&gt;TTR (search priority 4)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The logic behind should be the following:&lt;/P&gt;&lt;P&gt;Grab only one entire element by evaluating at first POD as value, if found grab it, if not found then evaluate LIV and grab it in case, if not found then evaluate AAR and grab it, and so on until you found a possible value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for any hints&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:34:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354547#M236931</guid>
      <dc:creator>Ray82</dc:creator>
      <dc:date>2022-10-11T14:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get only element based on a single parameter</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354549#M236933</link>
      <description>&lt;P&gt;I believe you could use QueryRecord to take you in the right direction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could define properties to route files based on their situation code, for example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Key: POD&lt;/P&gt;&lt;P&gt;Value: SELECT * FROM flowfile WHERE&amp;nbsp; situation_code = 'POD' LIMIT 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would route 1 element in your input array where the code is POD to the new relationship "POD" (same as the dynamic property name).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't exactly match your case of retrieving an element only if higher priority codes weren't found, but perhaps you could use this example to get closer to a solution. Good luck!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:49:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354549#M236933</guid>
      <dc:creator>Green_</dc:creator>
      <dc:date>2022-10-11T14:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Get only element based on a single parameter</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354555#M236935</link>
      <description>&lt;P&gt;Thanks for the update, however that's is the problem.&lt;/P&gt;&lt;P&gt;The Query Record does not fit my needs cause cannot implement the logic.&lt;/P&gt;&lt;P&gt;Note that the json doesn't have always all situation codes, so the pseudo code should be:&lt;/P&gt;&lt;P&gt;Grab the element with sit_code = POD only if present, otherwise go further with others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciate.&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 15:22:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354555#M236935</guid>
      <dc:creator>Ray82</dc:creator>
      <dc:date>2022-10-11T15:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get only element based on a single parameter</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354561#M236936</link>
      <description>Perhaps you can use the processor CalculateRecordStats to count how many&lt;BR /&gt;records of each situation code you have in a given file, then once that is&lt;BR /&gt;put in your attributes you can try a couple of different methods to decide&lt;BR /&gt;what to do, for example you can use RouteOnAttribute and then check if&lt;BR /&gt;attribute sit_code.pod&amp;gt;0 then send to extract_one_pod_element and there you&lt;BR /&gt;could use QueryRecord to take out exactly one POD element, otherwise route&lt;BR /&gt;to LIV, AAR, etc.&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Oct 2022 15:52:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354561#M236936</guid>
      <dc:creator>Green_</dc:creator>
      <dc:date>2022-10-11T15:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get only element based on a single parameter</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354661#M236953</link>
      <description>&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;it works like a charm!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:53:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-only-element-based-on-a-single-parameter/m-p/354661#M236953</guid>
      <dc:creator>Ray82</dc:creator>
      <dc:date>2022-10-12T14:53:24Z</dc:date>
    </item>
  </channel>
</rss>

