Support Questions

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

Is there a way for anyMatchingAttribute to work with references?

avatar
Explorer

As the question states I was wondering if it's possible to do something like:

anyMatchingAttribute(
${attributeToSearch}
).contains(${value})

 

Thank you

1 REPLY 1

avatar
Master Mentor

@Jacccs 

An example or detailed description of yoru use case may be helpful in providing the bets guidance for you.  While the NiFi Expression Language (NEL) function anyMatchingAttribute expects a java regular expression that searches and returns values for multiple FlowFile attributes, that does not appear to be what you need???  Your attribute "attributeToSearch" implies only a single specific FlowFile attribute is desire to be checked if it contains some "${value}".  If this is correct, you would be able to use the following NEL:

${literal("${${attributeToSearch}}"):contains('${value}')}


For above NEL, let's assume a FlowFile with attribute "attributeToSearch" set to "username".  A FlowFile attribute "username" set to "admin-matt".  A FlowFile attribute "value" set to "admin".

The result of above NEL statement would be true
${$attributeToSearch}} would first resolve to ${username} which would then resolve to "admin-matt".  That "admin-matt" string would be then passed to the NEL contains function which will to check to see if that string contains the string "admin" within it.  The result is a boolean "true" or "false".

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,

Matt