Support Questions

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

Duplicate results using extract text processor for key value data

avatar
New Contributor

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 Contributor

Thanks for your help!