Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Duplicate results using extract text processor for key value data

Solved Go to solution
Highlighted

Duplicate results using extract text processor for key value data

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

Accepted Solutions

Re: Duplicate results using extract text processor for key value data

Super 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 :-)

2 REPLIES 2

Re: Duplicate results using extract text processor for key value data

Super 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 :-)

Re: Duplicate results using extract text processor for key value data

New Contributor

Thanks for your help!

Don't have an account?
Coming from Hortonworks? Activate your account here