<?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: NiFi - Problems merging flow file content and attributes with replace text processor in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230428#M192278</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Could you show me the configuration off your Extract Content as Attribute Processor? I think thats the point where I'm struggling&lt;/P&gt;</description>
    <pubDate>Fri, 22 Dec 2017 22:24:49 GMT</pubDate>
    <dc:creator>lukas_mueller02</dc:creator>
    <dc:date>2017-12-22T22:24:49Z</dc:date>
    <item>
      <title>NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230422#M192272</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some problems merging the response of a API call with InvokeHTTP to the orginal flow file. I tried to put the response as an attribute to the original file and sent it to an replace text processor. I set the Evaluation Mode to Entire Text and tried either prepend and append replacement strategy. &lt;/P&gt;&lt;P&gt;In prepend mode the processor is just passing the attributes as new content and in append the processor is writing the original content to the flow files. Any ideas how to merge the both datasets?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45497-2017-12-20-112826-1920x1103-scrot.png" style="width: 1386px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15021i251242648BFFEC1E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45497-2017-12-20-112826-1920x1103-scrot.png" alt="45497-2017-12-20-112826-1920x1103-scrot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45498-2017-12-20-112822-1920x1103-scrot.png" style="width: 1076px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15022i186FDB0E63930F1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45498-2017-12-20-112822-1920x1103-scrot.png" alt="45498-2017-12-20-112822-1920x1103-scrot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45496-2017-12-20-112839-1920x1103-scrot.png" style="width: 804px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15023iC3B46B02457AE72E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45496-2017-12-20-112839-1920x1103-scrot.png" alt="45496-2017-12-20-112839-1920x1103-scrot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 00:47:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230422#M192272</guid>
      <dc:creator>lukas_mueller02</dc:creator>
      <dc:date>2019-08-18T00:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230423#M192273</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/29248/lukasmueller0289.html" nodeid="29248" target="_blank"&gt;@Lukas Müller&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;For your case we are having 2 json responses and trying to
merge them as one, we need to do some kind of preparing the json messages before doing merging them as one.&lt;/P&gt;&lt;P&gt;1.You need to remove the Closed braces after sensordatavalues
array you need to remove the last close braces } from the json response.&lt;/P&gt;&lt;P&gt;by using replace text processor with search value as &lt;STRONG&gt;(.*)}\Z&lt;/STRONG&gt;
and Replacement value as &lt;STRONG&gt;$1&lt;/STRONG&gt; Replacement strategy as Regex Replace.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45511-replacetext1.png" style="width: 888px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15018i6A20C345F1E47E5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45511-replacetext1.png" alt="45511-replacetext1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then extract the &lt;STRONG&gt;resultant content&lt;/STRONG&gt; as&lt;STRONG&gt; attribute to the flow
file&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;2.Then trigger &lt;STRONG&gt;invoke http processor&lt;/STRONG&gt; once you get the result.&lt;/P&gt;&lt;P&gt;Right now we are having a json response but we need to merge
our extracted output to the response and make it as one json message&lt;/P&gt;&lt;P&gt;3.for json response that you got from above invoke http
processor we need to remove the open braces { with Replace Text processor.&lt;/P&gt;&lt;P&gt;by using search value as &lt;STRONG&gt;^[{](.*)&lt;/STRONG&gt; and Replacement value as
&lt;STRONG&gt;$1 &lt;/STRONG&gt;Replacement strategy as &lt;STRONG&gt;Regex Replace&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Configs:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45512-replacetext2.png" style="width: 773px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15019i251D2B9C537EAABD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45512-replacetext2.png" alt="45512-replacetext2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;so the response from the invoke http processor we have removed the first open braces then use &lt;/P&gt;&lt;P&gt;4. Replace Text processor to prepare your required json message now by using Prepend with the attributed that we have extracted with extract text processor.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Extract text processor attribute value:- &lt;/STRONG&gt;i'm keeping this attribute name as &lt;STRONG&gt;extracted_Attribute&lt;/STRONG&gt; for testing&lt;/P&gt;&lt;PRE&gt;{  "id" : 590929682,  "sampling_rate" : null,  "timestamp" : "2017-12-19 16:00:58",  "location" : {  "id" : 2191,  "latitude" : "51.482",  "longitude" : "7.408",  "country" : "DE"  },  "sensor" : {  "id" : 4355,  "pin" : "1",  "sensor_type" : {  "id" : 14,  "name" : "SDS011",  "manufacturer" : "Nova Fitness"  }  },  "sensordatavalues" : [ {  "id" : 1292433314,  "value" : "90.53",  "value_type" : "P1"  } ]&lt;/PRE&gt;&lt;P&gt;like this way with out closing braces at the end&lt;/P&gt;&lt;P&gt;Then next replace text processor we are removing the &lt;STRONG&gt;first open braces&lt;/STRONG&gt; then the content should be like this way&lt;/P&gt;&lt;PRE&gt;"coord" : {  "lon" : 8.92,  "lat" : 48.85  },  "weather" : [ {  "id" : 300,  "main" : "Drizzle",  "description" : "light intensity drizzle",  "icon" : "09d"  }, {  "id" : 701,  "main" : "Mist",  "description" : "mist",  "icon" : "50d"  } ],  "base" : "stations",  "main" : {  "temp" : 276.69,  "pressure" : 1033,  "humidity" : 93,  "temp_min" : 276.15,  "temp_max" : 277.15  },  "visibility" : 10000,  "wind" : {  "speed" : 1  },  "clouds" : {  "all" : 75  },  "dt" : 1513765200,  "sys" : {  "type" : 1,  "id" : 4891,  "message" : 0.01,  "country" : "DE",  "sunrise" : 1513754085,  "sunset" : 1513783780  },  "id" : 2812053,  "name" : "Weissach",  "cod" : 200}&lt;/PRE&gt;&lt;P&gt;Then the &lt;STRONG&gt;next replace text processor which is going to prepare the merged json message properties would be like&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45513-replacetext.png" style="width: 949px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15020iD7F87AE9C0CAB2C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45513-replacetext.png" alt="45513-replacetext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For testing purpose i did this but you change the prepend and appends as per your json responses.&lt;/P&gt;&lt;P&gt;This is the way we can do merge 2 json responses and make it as one valid json message by using NiFi processors.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 00:47:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230423#M192273</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T00:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230424#M192274</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for you detailed reply. That seems very helpful to my porpuse. How did you attech the resulting content as attribute to the flow file?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2017 19:09:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230424#M192274</guid>
      <dc:creator>lukas_mueller02</dc:creator>
      <dc:date>2017-12-21T19:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230425#M192275</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/29248/lukasmueller0289.html" nodeid="29248"&gt;@Lukas Müller&lt;/A&gt;,&lt;BR /&gt;Use &lt;STRONG&gt;Replace text processor with above Configs&lt;/STRONG&gt; as i shown in&lt;STRONG&gt; last attached screenshot&lt;/STRONG&gt; then the Output of the processor will give you merged json message.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 00:21:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230425#M192275</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2017-12-22T00:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230426#M192276</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; I don't quiet understand that part because you mentioned extracting the content with an extract text processor? How did you implement that?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 21:15:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230426#M192276</guid>
      <dc:creator>lukas_mueller02</dc:creator>
      <dc:date>2017-12-22T21:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230427#M192277</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/29248/lukasmueller0289.html" nodeid="29248" target="_blank"&gt;@Lukas Müller&lt;/A&gt;&lt;P&gt;i think in your flow you are having 2 json responses&lt;/P&gt;&lt;PRE&gt;1. before invoke http processor(until 4 processor in the screenshot below)&lt;BR /&gt;2. after invoke http processor(after 4 processor in the screenshot)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Flow:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;1. Replace Text //to remove last closed braces using replace text processor)&lt;BR /&gt;2. Extract text //extract the content of the flowfile and keep as attribute&lt;BR /&gt;3. invoke http &lt;BR /&gt;4. Replace Text //To remove first Open braces { for the response of invoke http processor&lt;BR /&gt;5. Replace Text //merge the existing content of the flowfile with the extracted attribute(step2) &lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45525-flow.png" style="width: 1737px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15017iCD42FF9392A20BF2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45525-flow.png" alt="45525-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Let me know if you are not able to understand ..!!&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 00:46:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230427#M192277</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T00:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230428#M192278</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Could you show me the configuration off your Extract Content as Attribute Processor? I think thats the point where I'm struggling&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 22:24:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230428#M192278</guid>
      <dc:creator>lukas_mueller02</dc:creator>
      <dc:date>2017-12-22T22:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230429#M192279</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/29248/lukasmueller0289.html" nodeid="29248" target="_blank"&gt;@Lukas Müller&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45527-extracttext.png" style="width: 1955px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15016iEC78B6E85805D869/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45527-extracttext.png" alt="45527-extracttext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If your content is in &lt;B&gt;more than one new line&lt;/B&gt; then you need to change the following &lt;B&gt;properties to True&lt;/B&gt;. by &lt;B&gt;default &lt;/B&gt;these properties are &lt;B&gt;false&lt;/B&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Enable DOTALL Mode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;false&lt;/TD&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI&gt;true&lt;/LI&gt;&lt;LI&gt;false&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;Indicates
 that the expression '.' should match any character, including a line 
terminator.  Can also be specified via the embedded flag (?s).&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Enable Multiline Mode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;false&lt;/TD&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI&gt;true&lt;/LI&gt;&lt;LI&gt;false&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;Indicates
 that '^' and ' should match just after and just before a line 
terminator or end of sequence, instead of only the beginning or end of 
the entire input.  Can also be specified via the embeded flag (?m).&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;2.You need to change the below property if &lt;STRONG&gt;your extract content is more than 1024 B(1 KB)&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Maximum Capture Group Length&lt;/TD&gt;&lt;TD&gt;1024&lt;/TD&gt;&lt;TD&gt;Specifies
 the maximum number of characters a given capture group value can have. 
 Any characters beyond the max will be truncated.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;3. To extract whole content of the flowfile &lt;STRONG&gt;add new property&lt;/STRONG&gt; by clicking on &lt;STRONG&gt;+&lt;/STRONG&gt; sign at right corner&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;extract_Attribute&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;(.*) //matches everything&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 00:46:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230429#M192279</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T00:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Problems merging flow file content and attributes with replace text processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230430#M192280</link>
      <description>&lt;P&gt;@Shu that did the trick! Many thanks for your help and your patience as well. &lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 23:16:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Problems-merging-flow-file-content-and-attributes-with/m-p/230430#M192280</guid>
      <dc:creator>lukas_mueller02</dc:creator>
      <dc:date>2017-12-22T23:16:17Z</dc:date>
    </item>
  </channel>
</rss>

