RouteText 2.0.0

Bundle
org.apache.nifi | nifi-standard-nar
Description
Routes textual data based on a set of user-defined rules. Each line in an incoming FlowFile is compared against the values specified by user-defined Properties. The mechanism by which the text is compared to these user-defined properties is defined by the 'Matching Strategy'. The data is then routed according to these rules, routing each line of the text individually.
Tags
Expression Language, Regular Expression, attributes, csv, delimited, detect, filter, find, logs, regex, regexp, routing, search, string, text
Input Requirement
REQUIRED
Supports Sensitive Dynamic Properties
false
Properties
Dynamic Properties
Relationships
Name Description
unmatched Data that does not satisfy the required user-defined rules will be routed to this Relationship
original The original input file will be routed to this destination when the lines have been successfully routed to 1 or more relationships
Writes Attributes
Name Description
RouteText.Route The name of the relationship to which the FlowFile was routed.
RouteText.Group The value captured by all capturing groups in the 'Grouping Regular Expression' property. If this property is not set or contains no capturing groups, this attribute will not be added.
Use Cases
  • Drop blank or empty lines from the FlowFile's content.
    Description
    Drop blank or empty lines from the FlowFile's content.
    Keywords
    filter, drop, empty, blank, remove, delete, strip out, lines, text
    Configuration
    "Routing Strategy" = "Route to each matching Property Name"
    "Matching Strategy" = "Matches Regular Expression"
    "Empty Line" = "^$"
    
    Auto-terminate the "Empty Line" relationship.
    Connect the "unmatched" relationship to the next processor in your flow.
    
  • Remove specific lines of text from a file, such as those containing a specific word or having a line length over some threshold.
    Description
    Remove specific lines of text from a file, such as those containing a specific word or having a line length over some threshold.
    Keywords
    filter, drop, empty, blank, remove, delete, strip out, lines, text, expression language
    Configuration
    "Routing Strategy" = "Route to each matching Property Name"
    "Matching Strategy" = "Satisfies Expression"
    
    An additional property should be added named "Filter Out." The value should be a NiFi Expression Language Expression that can refer to two variables (in addition to FlowFile attributes): `line`, which is the line of text being evaluated; and `lineNo`, which is the line number in the file (starting with 1). The Expression should return `true` for any line that should be dropped.
    
    For example, to remove any line that starts with a # symbol, we can set "Filter Out" to `${line:startsWith("#")}`.
    We could also remove the first 2 lines of text by setting "Filter Out" to `${lineNo:le(2)}`. Note that we use the `le` function because we want lines numbers less than or equal to `2`, since the line index is 1-based.
    
    Auto-terminate the "Filter Out" relationship.
    Connect the "unmatched" relationship to the next processor in your flow.