Support Questions

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

How to use NiFi Expression Language with ExtractText

avatar
Explorer

I'm trying to use NiFi expression language with a custom property on the ExtractText processor. It appears that the ExtractText processor interprets the value literally and does not interpolate the value. Is there a way to achieve this?

 

DSan_0-1632750480341.pngDSan_1-1632750599274.png

 

 

 

java.util.regex.PatternSyntaxException: Illegal repetition near index 2
${start}
^
at java.base/java.util.regex.Pattern.error(Pattern.java:2028)
at java.base/java.util.regex.Pattern.closure(Pattern.java:3374)
at java.base/java.util.regex.Pattern.sequence(Pattern.java:2229)
at java.base/java.util.regex.Pattern.expr(Pattern.java:2069)
at java.base/java.util.regex.Pattern.compile(Pattern.java:1783)
at java.base/java.util.regex.Pattern.<init>(Pattern.java:1430)
at java.base/java.util.regex.Pattern.compile(Pattern.java:1095)
at org.apache.nifi.processors.standard.ExtractText.onScheduled(ExtractText.java:366)
at jdk.internal.reflect.GeneratedMethodAccessor483.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$4(StandardProcessorNode.java:1582)
at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)

1 ACCEPTED SOLUTION

avatar
Super Mentor

@DSan 

 

You run in to some unique challenges with your specific use case since the properties you want to enable NEL expect Java regular expressions.  The reserved characters that would tell NiFi that a NEL statement is being used are special characters in Java Regular expressions.

You may want to raise your change/improvement request as a Jira in the Apache NiFi Jira project:
https://issues.apache.org/jira/browse/NIFI

There may be others in the community that like this idea and have suggestions for working around the challenge I shared above.

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

View solution in original post

4 REPLIES 4

avatar
Explorer

I've noted this in the documentation:

 

"A FlowFile attribute A Regular Expression with one or more capturing group The first capture group, if any found, will be placed into that attribute name. But all capture groups, including the matching string sequence itself will also be provided at that attribute name with an index value provided. Supports Expression Language: false"

 

Is there not a boolean to toggle this on?

avatar
Super Mentor

@DSan 

 

Not all component (processor, controller service, reporting task, etc.) support the use of the NiFi Expression Language (NEL).  Dynamic properties added to the ExtractText processor do not support NEL.

For any existing property, you can float your cursor over the question mark next to the Property name to see if it support Full NEL, Partial NEL, or no NEL.

When adding a dynamic property to a processor that supports this capability, you will also see icon depicting NEL support:

MattWho_0-1632764411434.png

 

These dynamic properties in the ExtractText use Java Regular Expressions to extract text from the content of the inbound FlowFile.

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

avatar
Explorer

Hi Matt,

 

Thanks for the help and the useful pointers! Is it possible to extend the ExtractText class and create a custom NAR that is able to use NEL? Otherwise it looks like I'm back to developing in Python.

 

Thank you,

Dave

avatar
Super Mentor

@DSan 

 

You run in to some unique challenges with your specific use case since the properties you want to enable NEL expect Java regular expressions.  The reserved characters that would tell NiFi that a NEL statement is being used are special characters in Java Regular expressions.

You may want to raise your change/improvement request as a Jira in the Apache NiFi Jira project:
https://issues.apache.org/jira/browse/NIFI

There may be others in the community that like this idea and have suggestions for working around the challenge I shared above.

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt