Apache-Nifi: A Short Description of ifElse
Join the DZone community and get the full member experience.Join For Free
I had been working with Apache-NiFi for last few months at my work. During this period I mostly used
Recently, I got a problem with the following scenario.
flowfile, I needed to do a
regex operation on a column value and `replace` them with some other code. I did this easily using the
First, let's see what
replaceAll does in Apache-NiFi. It takes two string arguments, first one is a
regex and second is the replacement value.
For more details, I highly recommend reading Apache-NiFi expression language guide on replaceAll.
For the first attempt, I have used the following syntax for my column using
UpdateRecord processor :
This first checks whether the length of the column value is less than 8 characters. If so, it replaces that with
Undefined. But some data matched with
[a-z]+ pattern had been replaced with
Wrong, even though they are less than 8 characters.
If the subject is
true then, first argument is evaluated else second.
As given in the example:
bool is true. So, if I use
replaceAll with this, the value will be replaced with
In order to do my scenario using this, I had to change the logic by checking whether it has more than 8 characters and then applying my custom
regex based operations.
I hope this short description will give you a better understanding how to use
ifElse in Apache-NiFi.
Opinions expressed by DZone contributors are their own.