NiFi record path expression
Use this information to understand the different expressions that are available, what they do, and how they work.
- Target expressions, which produce value that can be assigned to target field, such as
substringAfter( /name, ' ' )
. A target expression can also be used within a filter but does not return a boolean (true or false value) and therefore cannot itself be an entire filter. For example, you can use a path such as[ substringAfter(/name, ' ') = 'Doe']
but you cannot use[ substringAfter(/name, ' ') ]
because doing so doesn’t really make sense, as filters must be boolean values. - Filter expressions, which are to be used as a filter, such as
[ contains(/name,'John') ]
.
Standalone functions
Function name | Description |
---|---|
substring |
substring(value (expression), start index (int), end index (int)) . The
substring function returns a portion of a String value. The function requires 3 arguments; the value
to take a portion of, the 0-based start index (inclusive), and the 0-based end index (exclusive).
The start index and end index can be 0 to indicate the first character of a String, a positive
integer to indicate the nth index into the string, or a negative integer. If the value is a negative
integer, say -n, then this represents the nth character for the end. A value of-1 indicates the last
character in the String. For example, |
substringAfter |
Expression function substringAfter(value (expression), pattern (literal)) .
Returns the portion of a String value that occurs after the first occurrence of some other
value. |
substringAfterLast |
expression function substringAfterLast(value (expression), pattern
(literal)) . Returns the portion of a String value that occurs after the last occurrence of some other value. |
substringBefore |
expression function substringBefore(value (expression), pattern (literal)) ,
pattern (literal)). Returns the portion of a String value that occurs before the first occurrence of some other value. |
substringBeforelLast |
Expression function substringBeforeLast(value (expression), pattern
(literal)) . Returns the portion of a String value that occurs before the last occurrence of some other value. |
replace |
Expression function replace(value (expression), pattern (literal), replace
(literal)) . Replaces all occurrences of a String with another String. |
replaceRegex |
Expression function replaceRegex(value (expression), pattern (regex), replace
(literal)) . Evaluates a Regular Expression against the contents of a String value and replaces any match with another value. This function requires 3 arguments; the String to run the regular expression against, the regular expression to run, and the replacement value. The replacement value may optionally use back-references, such as $1. |
concat |
Expression function concat(value (expression), ...) . Concatenates all the arguments together. |
fieldName |
Expression function fieldName(value (expression) . Normally, when a path is given to a particular field in a Record, what is returned is the value of that field. It can sometimes be useful, however, to obtain the name of the field instead of the value. To do this, we can use the fieldName function. |
toDate |
Expression function toDate(value (expression), format (literal), zone
(literal)) . Converts a String to a date. |
toString |
Expression function toString(value (expression), encoding (literal)) .
Converts a value to a String, using the given character set if the input type is "bytes" |
toBytes |
Expression function toBytes(value (expression), encoding (literal)) .
Converts a String to byte[], using the given character set. |
coalesce |
Expression function coalesce(value (expression), ...) . Returns the first value from the given arguments that is non-null. |
format |
Expression function format(value (expression), format (literal), zone
(literal)) . Converts a Date to a String in the given format with an optional time zone. |
trim |
Expression function trim(value (expression)) . Removes whitespace from the start and end of a string. |
toUpperCase |
Expression function toUpperCase(value (expression)) . Change the entire String to upper case. |
toLowerCase |
Expression function toLowerCase(value (expression)) . Changes the entire string to lower case. |
base64Encode |
Expression function base64Encode(value (expression)) . Converts a String using Base64 encoding, using the UTF-8 character set. |
base64Decode |
Expression function base64Decode(value (expression)) . Decodes a Base64-encoded String. |
escapeJson |
Expression function escapeJson(value (expression)) .JSON Stringifies a Record, Array or simple field (e.g. String), using the UTF-8 character set. |
unescapeJson |
Expression function unescapeJson(value (expression)) . Converts a stringified JSON element to a Record, Array or simple field (e.g. String), using the UTF-8 character set. |
hash |
Expression function hash(value (expression), algorithm (literal)) .
Converts a String using a hash algorithm (HA-384, SHA-224, SHA-256, MD2, SHA, SHA-512, MD5). |
padLeft |
Expression function padLeft(value (expression), length (int), pad
(literal)) . Prepends characters to the input String until it reaches the desired length. |
padRight |
Expression function padRight(value (expression), length (int), pad
(literal)) . Appends characters to the input String until it reaches the desired length. |
uuid5 |
Expression function uuid5(value (expression), namespace (expression)) .
Inserts a UUID v5 into the target field. |
zipValue |
Expression function zipValue(key (expression), value (expression), field (literal),
delimiter (literal)) . zip key string and value strings and get value for given field name
using given delimiter. |
delimitedField |
Expression function delimitedField(value (expression), index (literal number),
delimiter(literal)) . Splits value by delimiter if given, otherwise by spaces and get field value at index. |
csvLookup |
Expression function csvLookup(lookupName (literal), key (expression), default
(expression)) . Returns look up value from CSV. Currently, only default value is used and the the actual lookup should be directly implemented in NiFi common template. |
path |
Expression function (/) |
property |
Expression function (without prefix slash or surrounded qoutes) |
identifier |
Expression function internal |
literalString |
Expression function (surrounded by quotes) |
literalNumber |
Expression function (value number including decimal and scientific numbers) |
Filter functions
Function name | Description |
---|---|
equal |
conditional filter (=) |
notEqual |
Conditional filter (!=) |
greater |
Conditional filter (>) |
greaterAndEqual |
Conditional filter (>=) |
lesser |
Conditional filter (<) |
lesserAndEqual |
Conditional filter (<=) |
contains |
Conditional filter contains(value (expression), pattern (literal)) .
Returns true if a string value contains the provided substring, false otherwise. |
matchesRegex |
Conditional filter matchesRegex(value (expression), pattern (regex)) .
Evaluates a Regular Expression against the contents of a string value and returns true if the Regular Expression exactly matches the String value, false otherwise. |
startsWith |
Conditional filter startsWith(value (expression), pattern (literal)) .
Returns true if a string value starts with the provided substring, false otherwise. |
endsWith |
Conditional filter endsWith(value (expression), pattern (literal)) .Returns true if a string value ends with the provided substring, false otherwise. |
not |
Conditional filter not(value (condition)) .Inverts the value of the function or expression that is passed into the not function. |
isEmpty |
Conditional filter isEmpty(value (expression)) . Returns true if the provided value is either null or is an empty string. |
isBlank |
Conditional filter isBlank(value (expression)) . Returns true if the provided value is either null or is an empty string or a string that consists only of white space (spaces, tabs, carriage returns, and new-line characters). |
zipContains |
Conditional filter zipContains(key (expression), value (expression), field (literal),
delimiter (literal)) . zip key string and value strings and test if it contains given field name using given delimiter. |