Support Questions

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

How to use (in) to compare variable with array?

avatar

I have two flow file:

1) $.category = sport

2) $.temp_array = "music" , "sport" , "traveling"

I just want to check $.category is exist in $.temp_array or not using in expression language.

Ex.

${category:in(${temp_array})} 

But it doesn't work with array or (variable). I have used this login on RouteOnAttribute processor. Instead of above example if i write like this:

${category:in("music","sport","traveling")}

then ii will give you perfect output But this is static data. Instead of this i want to use dynamic.

Please help.

1 ACCEPTED SOLUTION

avatar
Super Mentor
@umang s

The following NiFi Expression Language statement will return "true" if a match is found:

${anyDelineatedValue("${temp_array}", ","):contains("${category}")}

-

Thanks,

Matt

-

If you found this Answer addressed your original question, please take a moment to login and click "Accept" below the answer.

View solution in original post

3 REPLIES 3

avatar
Super Mentor
@umang s

The following NiFi Expression Language statement will return "true" if a match is found:

${anyDelineatedValue("${temp_array}", ","):contains("${category}")}

-

Thanks,

Matt

-

If you found this Answer addressed your original question, please take a moment to login and click "Accept" below the answer.

avatar

@Matt Clarke

it doesn't work.
It directly goes to unmatched. Means condition is not worked.

I have attached

flow and configuration of RouteOnAttribute processor

80423-flow.jpg

Configuration of RouteOnAttribute Processor

80424-routeonattributeconfiguration.jpg

avatar
Super Mentor

@umang s

Based on your flow design above, it looks like you are trying to route FlowFiles by comparing attribute between two different FlowFiles? That will not work. NiFi is looking for both ${temp_array} and ${category} to exist on same flowfile being evaluated by the RouteOnAttribute processor.