Support Questions

Find answers, ask questions, and share your expertise

Merge Attribute values from FlowFiles

avatar
Expert Contributor

Hello together,

 

I splitted a flow file for each x value.

With value x I fetch value y and set it to the Attribute.


Is it possible if I merge the FlowFiles together, that the Attribute values can be merged comma-seperated too?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Faerballert 

Perhaps you clone your flowfile before the mergeContent processors. So whichever relationship you are connecting to your current mergeContent, you drag a second connection containing that same relationship to a parallel notification flow.

Down this parallel flow path you use a replaceText processor to replace the content with the value from the attribute you want to merge.  Then you use a mergeContent processor on this path to merge these files using a "," as your delimiter.   Then from this mergeContent you do you notification.

You may also want to open an Apache Jira with your use case and desired improvement for the existing mergeContent.  The more details the better.

Hope this helps,

Matt

View solution in original post

3 REPLIES 3

avatar
Master Mentor

@Faerballert 

 

The NiFi merge based processors only offer the option to "Keep Common Attributes" (keeps on attributes were every merged file has same attributes with same value) or "Keep all Unique Attributes" (same as above, but will also keep attributes that is unique.  This means any attribute that exists in 1 or more of the merged FlowFiles were the value assigned to that attribute is the same in cases where attribute was found on more than one FlowFile being merged).

 

There is no option to merge all attributes creating a comma separated list of unique values.   What is the use case for such a n attribute merge need?  There is no way to tell which value goes with which chunk of the merged data. Plus if the merged FlowFile were later split, every produced split FlowFile would have all the same FlowFile attributes.

Hope this helps,
Matt

avatar
Expert Contributor

thanks @MattWho for your answer.

The goal for me is to create an output with the merged attributes so that I can notify myself what elements have been edited.

 

My thought was to mail me something like this:

Postion 1,2,3,5,8,13 has been changed

*1,2,3,5,8,13 are the attribute values of each flowfile

 

Dont know how i can solve this otherwise in one Flow/Notification

avatar
Master Mentor

@Faerballert 

Perhaps you clone your flowfile before the mergeContent processors. So whichever relationship you are connecting to your current mergeContent, you drag a second connection containing that same relationship to a parallel notification flow.

Down this parallel flow path you use a replaceText processor to replace the content with the value from the attribute you want to merge.  Then you use a mergeContent processor on this path to merge these files using a "," as your delimiter.   Then from this mergeContent you do you notification.

You may also want to open an Apache Jira with your use case and desired improvement for the existing mergeContent.  The more details the better.

Hope this helps,

Matt