- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to use (in) to compare variable with array?
- Labels:
-
Apache NiFi
Created ‎07-06-2018 11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created ‎07-06-2018 12:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created ‎07-06-2018 12:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created on ‎07-07-2018 06:35 AM - edited ‎08-18-2019 02:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it doesn't work.
It directly goes to unmatched. Means condition is not worked.
I have attached
flow and configuration of RouteOnAttribute processor
Configuration of RouteOnAttribute Processor
Created ‎07-10-2018 01:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
