Created 09-27-2021 06:51 AM
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?
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)
Created 09-30-2021 06:10 AM
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
Created 09-27-2021 08:35 AM
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?
Created 09-27-2021 10:44 AM
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:
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
Created 09-27-2021 03:23 PM
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
Created 09-30-2021 06:10 AM
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