nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Wing <jvw...@gmail.com>
Subject Re: Dynamic attributes on repeating capture groups
Date Tue, 01 Aug 2017 05:11:07 GMT
I think you will need to use an ExecuteScript processor to nicely format
your data into attributes into the foo1=bar1 pattern.  I'm assuming here
that you cannot predict what the key names 'foo1', 'foo2', etc. will
actually be.  If you could predict those field names, an UpdateAttribute
processor with a brute-force list of keys might be ok if you can handle the
misses downstream using expressions with isEmpty() or something similar.

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-scripting-nar/1.3.0/org.apache.nifi.processors.script.ExecuteScript/index.html

Thanks,

James

On Mon, Jul 31, 2017 at 1:26 PM, wildo <willy.demis@moserit.com> wrote:

> I am parsing a text file with semi-formatted data. I use the SplitContent
> processor to get me each "block" of data- basically each object, and then
> the ExtractText processor to get all the individual properties that will be
> associated to that object.
>
> So I might have a flowfile with data:
>
> foo1: bar1
> foo2: bar2
> foo3: bar3
>
> When I push that flowfile into the ExtractText processor (which has "Enable
> repeating capture group" set to true) and run my capture group regex on it,
> I'm left with dynamic, numerated attributes. If I call my dynamic attribute
> "fields" then my flowfile attrs will have:
>
> fields.1 --> foo1
> fields.2 --> bar1
> fields.3 --> foo2
> fields.4 --> bar2
> fields.5 --> foo3
> fields.6 --> bar3
>
> Now I'd like to push this flowfile into an UpdateAttribute and turn my
> dynamic list into real, accessible attributes. The intention would then be
> to go into an AttributesToJSON processor.
>
> The question is: how do I configure the UpdateAttribute processor to have a
> new attribute of "foo1" using "fields.n" with a value of "bar1" using
> "field.n+1" and then dynamically add the other five as well?
>
> It seems like the ability to store repeating capture groups as attributes
> must imply that theirs a way to actually USE those attributes dynamically.
> What am I missing here?
>
>
>
> --
> View this message in context: http://apache-nifi-developer-
> list.39713.n7.nabble.com/Dynamic-attributes-on-repeating-capture-groups-
> tp16540.html
> Sent from the Apache NiFi Developer List mailing list archive at
> Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message