<?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: How to Combine Data from Two Flows Based on Common Attribute in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178126#M77585</link>
    <description>&lt;P&gt;I wrote up a quick Chain spec you can use in a &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.JoltTransformJSON/index.html" target="_blank"&gt;JoltTransformJSON&lt;/A&gt; processor, that way you can skip the Split/Merge pattern and work on the entire JSON object at once:&lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "Objects": {
        "*": {
          "Item": {
            "Inventory": {
              "Elements": {
                "Element": {
                  "*": {
                    "Height": "[&amp;amp;1].Height",
                    "Weight": "[&amp;amp;1].Weight",
                    "Features": {
                      "Feature": {
                        "*": "[&amp;amp;3].&amp;amp;"
                      }
                    }
                  }
                }
              }
            },
            "Status": {
              "ElementsStatus": {
                "ElementStatus": {
                  "*": {
                    "@(3,Id)": "[&amp;amp;1].Id",
                    "Status": "[&amp;amp;1].Status"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
]&lt;/PRE&gt;&lt;P&gt;Note that this assumes the Element and ElementStatus arrays are parallel, meaning the first object in the Element array corresponds to the first object in the ElementStatus array (i.e. their FeatureId fields match). If that is not true, you'd either need a more complicated JOLT spec or perhaps a scripted solution using &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-scripting-nar/1.6.0/org.apache.nifi.processors.script.ExecuteScript/index.html" target="_blank"&gt;ExecuteScript&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Tue, 01 May 2018 01:24:08 GMT</pubDate>
    <dc:creator>mburgess</dc:creator>
    <dc:date>2018-05-01T01:24:08Z</dc:date>
    <item>
      <title>How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178124#M77583</link>
      <description>&lt;P&gt;I have a json object in the following format&lt;/P&gt;&lt;PRE&gt;{
	"Objects": [
		{
			"Item": {
				"LastUpdateTime": "2018-03-23T02:36:09.000Z",
				"Identification": {
					"id": "123"
				},
				"Inventory": {
					"Elements": {
						"Element": [
							{
								"Height": 10,
								"Weight": 56,
								"Features": {
									"Feature": {
										"FeatureId": "456",
										"Color": "white"
									}
								}
							},
							{
								"Height": 14,
								"Weight": 46,
								"Features": {
									"Feature": {
										"FeatureId": "789",
										"Color": "orange"
									}
								}
							},
							{
								"Height": 40,
								"Weight": 68,
								"Features": {
									"Feature": {
										"FeatureId": "343",
										"Color": "yellow"
									}
								}
							}
						]
					}
				},
			"Status": {
				"Id": "123",
				"ElementsStatus": {
					"ElementStatus": [
						{
							"FeatureId": "456",
							"Status": "In-Stock"
						},
						{
							"FeatureId": "789",
							"Status": "Out Of Stock"
						},
						{
							"FeatureId": "343",
							"Status": "Out Of Stock"
						}
					]
					}
				}
			}
		}
	]
}
&lt;/PRE&gt;&lt;P&gt;, would like to create another object out of it in the current format&lt;/P&gt;&lt;PRE&gt;[{'Id': 123,
  'FeatureId': '456',
  'Color': 'White',
  'Height': 10,
  'Weight': 56,
  'Status': 'In-Stock'},
 {'Id': 123,
  'FeatureId': '789',
  'Color': 'orange',
  'Height': 14,
  'Weight': 46,
  'Status': 'Out Of Stock'},
 {'Id': 123,
  'FeatureId': '343',
  'Color': 'yellow',
  'Height': 40,
  'Weight': 68,
  'Status': 'Out Of Stock'}]
&lt;/PRE&gt;&lt;P&gt;The "Objects" object is an array of multiple items and their statuses, each item in the Inventory&amp;gt;Elements&amp;gt;Element should have an entry in Status&amp;gt;ElementsStatus&amp;gt;ElementStatus with the same "FeatureId"&lt;/P&gt;&lt;P&gt;My current process includes a SplitJson processor that splits each element in the "Objects" Array into a flowfile, then I have two EvaluateJsonPath processors to extract $.Objects.Item.Inventory.Elements.Element and $.Objects.Status.ElementsStatus.ElementStatus from each flow file. In the case above, each EvaluateJsonPath will output 3 flowfiles&lt;/P&gt;&lt;P&gt;The Challenge is to piece that data back together and output a similar format to what I showed above.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 06:54:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178124#M77583</guid>
      <dc:creator>do3bol85</dc:creator>
      <dc:date>2018-04-24T06:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178125#M77584</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; I am new here and not sure what's the best way to get a response, saw you're answering many questions, thought you might be able to help&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 00:54:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178125#M77584</guid>
      <dc:creator>do3bol85</dc:creator>
      <dc:date>2018-05-01T00:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178126#M77585</link>
      <description>&lt;P&gt;I wrote up a quick Chain spec you can use in a &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.JoltTransformJSON/index.html" target="_blank"&gt;JoltTransformJSON&lt;/A&gt; processor, that way you can skip the Split/Merge pattern and work on the entire JSON object at once:&lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "Objects": {
        "*": {
          "Item": {
            "Inventory": {
              "Elements": {
                "Element": {
                  "*": {
                    "Height": "[&amp;amp;1].Height",
                    "Weight": "[&amp;amp;1].Weight",
                    "Features": {
                      "Feature": {
                        "*": "[&amp;amp;3].&amp;amp;"
                      }
                    }
                  }
                }
              }
            },
            "Status": {
              "ElementsStatus": {
                "ElementStatus": {
                  "*": {
                    "@(3,Id)": "[&amp;amp;1].Id",
                    "Status": "[&amp;amp;1].Status"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
]&lt;/PRE&gt;&lt;P&gt;Note that this assumes the Element and ElementStatus arrays are parallel, meaning the first object in the Element array corresponds to the first object in the ElementStatus array (i.e. their FeatureId fields match). If that is not true, you'd either need a more complicated JOLT spec or perhaps a scripted solution using &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-scripting-nar/1.6.0/org.apache.nifi.processors.script.ExecuteScript/index.html" target="_blank"&gt;ExecuteScript&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 01:24:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178126#M77585</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-05-01T01:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178127#M77586</link>
      <description>&lt;P&gt;Thanks, that was fast, yes, the arrays are parallel. Will check this out and let you know&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 01:36:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178127#M77586</guid>
      <dc:creator>do3bol85</dc:creator>
      <dc:date>2018-05-01T01:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178128#M77587</link>
      <description>&lt;P&gt;Jolt Transformation did it for me, I didn't know how to use it and what it's meant to do, my document had more objects that I masked for public use, edited your transformation and things turned out pretty well.&lt;BR /&gt;What's the use of &amp;amp; in Jolt syntax? I noticed that it could bring up an object to a higher level based on the number you insert, is there a good reference or examples on the transformations?&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 05:12:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178128#M77587</guid>
      <dc:creator>do3bol85</dc:creator>
      <dc:date>2018-05-01T05:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Data from Two Flows Based on Common Attribute</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178129#M77588</link>
      <description>&lt;P&gt;I use the Advanced UI in the JoltTransformJSON processor or &lt;A href="http://jolt-demo.appspot.com/" target="_blank"&gt;this webapp&lt;/A&gt; to test out specs, also there are a bunch of examples and doc in the &lt;A href="https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Shiftr.java#L30" target="_blank"&gt;javadoc&lt;/A&gt; but it can be a bit difficult to follow. You can also search the jolt tag on StackOverflow for a number of questions, answers, and examples.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 20:52:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Combine-Data-from-Two-Flows-Based-on-Common-Attribute/m-p/178129#M77588</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-05-04T20:52:08Z</dc:date>
    </item>
  </channel>
</rss>

