Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi Expression - Multiple OR - AND Conditions

avatar
Contributor

Hi,

I am using RouteONAttribute Processor and i defined a property and its value contains multiple OR and AND conditions like the following:

Property Name: ROUTE1

Property Value:

${text.tag.type:equals('XXX'):and(${txt:contains('YES')}):or(${text.tag.type:equals('YYY')}):and(${txt:contains('NO')})}

The Issue i am facing is that after generating a flow file with attributes text.tag.type = XXX and txt = YES CORRECT it always route to unmatched while it should route to ROUTE1

Thanks ...

1 ACCEPTED SOLUTION

avatar
Master Guru
@yazeed salem

Method1:Using UpdateAttribute+RouteOnAttribute Processors

it would be easier if you introduce new update attribute processor before RouteOnAttribute and prepare two new attributes in UpdateAttribute processor.

Configs:

92479-screen-shot-2018-09-18-at-84637-pm.png

Then in RouteOnAttribute processor use or function to
Configs:

92480-screen-shot-2018-09-18-at-84747-pm.png

Now processor will route the flowfile to ROUTE1 relationship.

(or)

Method2: By using RouteOnAttribute processor:

Use the below expression in ROUTE1 property value

ROUTE1

${literal(${text.tag.type:equals('XXX'):and(${txt:contains('YES')})}):or(${text.tag.type:equals('YYY'):and(${txt:contains('NO')})})}

92481-screen-shot-2018-09-18-at-85322-pm.png

Both Methods will result the flowfile into ROUTE1 relationship, Choose the method which best for your case.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

View solution in original post

2 REPLIES 2

avatar
Master Guru
@yazeed salem

Method1:Using UpdateAttribute+RouteOnAttribute Processors

it would be easier if you introduce new update attribute processor before RouteOnAttribute and prepare two new attributes in UpdateAttribute processor.

Configs:

92479-screen-shot-2018-09-18-at-84637-pm.png

Then in RouteOnAttribute processor use or function to
Configs:

92480-screen-shot-2018-09-18-at-84747-pm.png

Now processor will route the flowfile to ROUTE1 relationship.

(or)

Method2: By using RouteOnAttribute processor:

Use the below expression in ROUTE1 property value

ROUTE1

${literal(${text.tag.type:equals('XXX'):and(${txt:contains('YES')})}):or(${text.tag.type:equals('YYY'):and(${txt:contains('NO')})})}

92481-screen-shot-2018-09-18-at-85322-pm.png

Both Methods will result the flowfile into ROUTE1 relationship, Choose the method which best for your case.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

avatar

@Shu


can i use this with filename i mean i would like to filename after validating two conditions in RouteONAttribute

${filename:contains("csv.done")}:and ${filename:contains(".csv")}