100% found this document useful (1 vote)
1K views

Nifi Expression Language Cheat Sheet

The document provides a cheat sheet for the Apache Nifi Expression Language, summarizing its reserved characters, logic operators, text search functions, type conversion functions, mathematical functions, date/time functions, encoding/decoding functions, string manipulation functions, and functions for working with multiple attributes. It allows extracting values from flow files and attributes using expressions.

Uploaded by

vanduc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

Nifi Expression Language Cheat Sheet

The document provides a cheat sheet for the Apache Nifi Expression Language, summarizing its reserved characters, logic operators, text search functions, type conversion functions, mathematical functions, date/time functions, encoding/decoding functions, string manipulation functions, and functions for working with multiple attributes. It allows extracting values from flow files and attributes using expressions.

Uploaded by

vanduc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Apache Nifi Expression Language Cheat Sheet 

Reserved Characters  Logic Operators  Text Search 


If these characters are present in attribute  isNull() ${filename:isNull()} filename:equals('fizz buzz bazz.txt') 
names they need to be quoted   
   notNull() ${filename:notNull()} startsWith  ${filename 
$ | { } ( ) [ ] , : ; / * '   (string) :startsWith('fizz')}
isEmpty() ${literal('') 
(space) \t \r \n  
  :isEmpty()} endsWith  ${filename 
Ex.​ ${'a:attribute name'}   (string) :endsWith('txt')}
equals(string) ${filename 
${"a:attribute name"}  Contains  ${filename 
:equals('value')}
  (string) :contains('buzz')}
equalsIgnoreCase ${filename 
Type Conversion  (string) :equalsIgnoreCase('v')}
in(string,   
string...)
${literal('NO') 
:in('NO','NOT')}
gt(number) ${fileSize:gt(64)} indexOf(string) ${filename 
Coerces from one format to another  :indexOf('buzz')} == 5
ge(number) ${fileSize:ge(64)}
toString() ${literal(2):toString()  lastIndexOf  ${filename 
:equals('2')}  lt(number) ${fileSize:lt(64)} (string) :lastIndexOf('z')} == 13
le(number) ${fileSize:le(64)} find(regex) ${filename:find('.*zz')}
toNumber() ${literal('2'):toNumber() 
:equals(2) }  and(bool) ${fileSize:gt(1)  matches(regex) ${filename 
:matches('fizz.*txt')}
toDecimal() ${filesize:toDecimal()} :and({fileSize:lt(4)})}
jsonPath(path) ${theJson 
  or(bool) ${fileSize:lt(1)  :jsonPath('$.attribute')}
:or(${fileSize:gt(4)})}
Mathematical   
not() ${filename  Utilities 
:endsWith('sv'):not()}}
plus()  ${fileSize:plus(10)} 
ifElse  ${filename  These subjectless functions provide useful 
minus()  ${fileSize:minus(10)}  utilities. 
('true val',    :endsWith('csv') 
multiply()  ${fileSize:multiply(10)}  'falseval') :ifElse('is csv',    
ip() local ip
divide()  ${fileSize:divide(10)}  'is not csv')}
  hostname(bool) ${hostname(true)} 
mod()  ${fileSize:mod(10)}  fully qualified hostname
toRadix()  ${fileSize:toRadix(10)}  Date/Time  unique generated UUID
UUID()
 
format is the java ​
SimpleDateFormat  nextInt() system wide counter, not 
Encode/Decode Functions    maintained through restart
format(format,  ${aDate  literal(value) ${literal(2):gt(1)}
zone)  :format('yy/MM/dd','GMT')} 
${message:function()}  getStateValue  ${getStateValue('hash')}
Functions: escapeJson, escapeXml, escapeCsv,  toDate  ${literal('99/12/31') 
(key)
escapeHtml3, escapeHtml4, unescapeJson,  (format,zone)  :toDate('yy/MM/dd','GMT')} 
unescapeXml, unescapeCsv, unescapeHtml3,  now()  ${now():toNumber()}  thread() Thread name
unescapeHtml4, urlEncode, urlDecode,  milliseconds since epoch   
base64Encode, base64Decode   

https://nifi.rocks 
   

String Manipulation  Multiple Attributes


Examples use filename equal to 'fizz buzz bazz.txt'  anyAttribute(  ${anyAttribute('bizz','bazz') 
toUpper() ${filename:toUpper()} 'attr1','attr2'...) :contains('value')}

toLower() ${filename:toLower()} allAttributes  ${allAttributes('bizz','bazz') 


('attr1',    :contains('value')}
trim ${literal('abc '):trim()} ​
'abc'
'attr2'...)
substring(start,end) ${filename:substring(0, 3)} '
​abc' anyMatchingAttribute(regex) ${anyMatchingAttributes('b.*zz') 
substringBefore(string) ${filename:substringBefore('zz')} '
​fi' :contains('value')}
substringBeforeLast  ${filename:substringBeforeLast('zz')}  allMatchingAttributes(regex ${allMatchingAttributes('b.*zz') 
(string) 'fizz buzz ba' ) :contains('value') }
substringAfter(string) ${filename:substringAfter('zz')}  anyDelineatedValue(value,   ${anyDelineatedValue( 
' buzz bazz.txt' delimiter) ${literal('a-b-c')},'-' 
substringAfterLast  ${filename:substringAfterLast('zz')}  ):contains('a')}
(string) '.txt' allDelineatedValues(value,   ${allDelineatedValues( 
getDelimitedField(  ${filename:getDelimitedField(2, ' ')}  delimiter) ${literal('a-b-c')}, '-' 
index, delimiter,    buzz ):contains('a)} f​alse
quote char, escape    join(string) ${allAttributes('attr1','attr2') 
char, strip char) :join(', ')}
append(string) ${filename:append('.bck')}  count() ${allMatchingAttributes('b.*zz') 
'fizz buzz bazz.txt.bck' :count()} ​number of matching
prepend(string) ${filename:prepend('a ')}   
'a fizz buzz bazz.txt'

replace(search,replace) ${ filename:replace(' ','_')} 


fizz_buzz_bazz.txt

replaceFirst(search,   ${filename:(' ', '_')} 


replace fizz_buzz bazz.txt

replaceAll(regex,  ${filename:replaceAll 
replace) ('(\w{4})\s', '!$1')} 
!fizz!buzzbazz.txt

replaceNull(replace) ${idonotexist:('abc') 
:replaceNull('abc')} 
'abc'

replaceEmpty(replace) ${literal(''):replaceEmpty('abc')} 
'abc'
length ${filename:length()} ​
18

https://nifi.rocks 

You might also like