Created 05-31-2021 06:05 AM
Hi,
I have many flow file which has multiple field like mentioned below
customefields_12345 : null
customefields_12346: { "welcome to this issue"}
I have to route these flow files on the condition :
if customfield is null --> navigate to other processor
if customfield is notnull or having some value other than null should be navigate to other processor.
Please let me know how to achieve this. early response will be appreciated.
Note: customfield should be used rather than customfield_12345.
thanks!
Created 06-02-2021 07:52 AM
I am not clearly following your use case.
FlowFiles consist of two parts, FlowFile attributes/metadata and FlowFile content.
You give example with "customefields_12345" and "customefields_12346".
Does this mean one FlowFile may have multiple "customefields_<some string>" attributes assigned to it?
How do you want to route FlowFiles where only some of those customfield attributes are null while others are not?
There are multiple ways to handle this using NiFi Expression Language (NEL) [1] and the routeOnAttribute [2] processor.
${anyMatchingAttribute("customfield.*"):isEmpty()}
Above would return "true" if ANY of the NiFi FlowFile attributes starting with "customefield" is empty.
note: The isEmpty function returns true if the Subject is null, does not contain any characters or contains only white-space (new line, carriage return, space, tab), false otherwise.
There is another NEL subjectless function that would return "true" only if ALL FlowFileAttributes matching the Java regular expression were empty:
${allMatchingAttributes("customfield.*"):isEmpty()}
With the RouteOnAttribute processor you create/add dynamic properties and each of those becomes a new routable relationship on the processor. if the NEL statement configured for that dynamic property returns true that FlowFile routes to that relationship. Any FlowFile that does not return true for dynamic properties will get routed to the pre-existing relationship named "unmatched".
[1] https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html
If you found this addressed your query, please take a moment to login and click "Accept" on this solution.
Thank you,
Matt
Created 06-02-2021 07:52 AM
I am not clearly following your use case.
FlowFiles consist of two parts, FlowFile attributes/metadata and FlowFile content.
You give example with "customefields_12345" and "customefields_12346".
Does this mean one FlowFile may have multiple "customefields_<some string>" attributes assigned to it?
How do you want to route FlowFiles where only some of those customfield attributes are null while others are not?
There are multiple ways to handle this using NiFi Expression Language (NEL) [1] and the routeOnAttribute [2] processor.
${anyMatchingAttribute("customfield.*"):isEmpty()}
Above would return "true" if ANY of the NiFi FlowFile attributes starting with "customefield" is empty.
note: The isEmpty function returns true if the Subject is null, does not contain any characters or contains only white-space (new line, carriage return, space, tab), false otherwise.
There is another NEL subjectless function that would return "true" only if ALL FlowFileAttributes matching the Java regular expression were empty:
${allMatchingAttributes("customfield.*"):isEmpty()}
With the RouteOnAttribute processor you create/add dynamic properties and each of those becomes a new routable relationship on the processor. if the NEL statement configured for that dynamic property returns true that FlowFile routes to that relationship. Any FlowFile that does not return true for dynamic properties will get routed to the pre-existing relationship named "unmatched".
[1] https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html
If you found this addressed your query, please take a moment to login and click "Accept" on this solution.
Thank you,
Matt