- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Duplicate results using extract text processor for key value data
- Labels:
-
Apache NiFi
Created ‎07-03-2019 11:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created ‎07-04-2019 03:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 🙂
Created ‎07-04-2019 03:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 🙂
Created ‎07-04-2019 12:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help!
