Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Duplicate results using extract text processor for key value data

avatar
New Member

If i use an extract text processor to extract a key and value from a text, then i always get 2 attributes with the same value.


For example:

If i use test: ([\w .]+) as my expression, then when i process a file with content "test: me" then the single data capture produces two attributes which as far as i can see are exactly the same.


myattribute : "me"

myattribute.1 : "me"


Is there any way i can configure this to get just 1 attribute? Or is there a better way to extract key= value data from a file content?

eg. attribute1:500, attribute2:600


Many thanks in advance.



1 ACCEPTED SOLUTION

avatar
Master Guru

@Matt Field

From NiFi ExtractText docs:

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.

This is an expected behaviour from NiFi as you are having capture group in your regular expression, so extract text processor adds index value to attribute name.

For consistency use ${myattribute} without index value as the reference for the attribute value.

-

If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂

View solution in original post

2 REPLIES 2

avatar
Master Guru

@Matt Field

From NiFi ExtractText docs:

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.

This is an expected behaviour from NiFi as you are having capture group in your regular expression, so extract text processor adds index value to attribute name.

For consistency use ${myattribute} without index value as the reference for the attribute value.

-

If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂

avatar
New Member

Thanks for your help!