Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

search lines in a file

avatar

I new in Apache Nifi and I'd like searh a text in the lines of a text file . The lines that match get write in the File. Is this possible with Apache nifi?

1 ACCEPTED SOLUTION

avatar
Master Guru

@sandra Alvarez

You can use RouteText processor

Routes textual data based on a set of user-defined rules. Each line in an incoming FlowFile is compared against the values specified by user-defined Properties. The mechanism by which the text is compared to these user-defined properties is defined by the 'Matching Strategy'. The data is then routed according to these rules, routing each line of the text individually.

Example:

I have an input data as follows:

nifi hdf
kyjkglhkghfgdsa
hdp jdfdf nifi

RouteText configs:

Route text processor having alot of ways to determine Matching Strategy and i'm using contains strategy and added new dynamic property as

required

nifi

86613-routetext.png

the matched relationship from RouteText processor will give

nifi hdf
hdp jdfdf nifi

Only the above two lines having nifi in them so processor given results as expected.

Like this way you can choose any of Matching Strategy and add dynamic properties based on the strategies(i.e match regular expression means your dynamic property will be REGEX).

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

View solution in original post

2 REPLIES 2

avatar
Master Guru

@sandra Alvarez

You can use RouteText processor

Routes textual data based on a set of user-defined rules. Each line in an incoming FlowFile is compared against the values specified by user-defined Properties. The mechanism by which the text is compared to these user-defined properties is defined by the 'Matching Strategy'. The data is then routed according to these rules, routing each line of the text individually.

Example:

I have an input data as follows:

nifi hdf
kyjkglhkghfgdsa
hdp jdfdf nifi

RouteText configs:

Route text processor having alot of ways to determine Matching Strategy and i'm using contains strategy and added new dynamic property as

required

nifi

86613-routetext.png

the matched relationship from RouteText processor will give

nifi hdf
hdp jdfdf nifi

Only the above two lines having nifi in them so processor given results as expected.

Like this way you can choose any of Matching Strategy and add dynamic properties based on the strategies(i.e match regular expression means your dynamic property will be REGEX).

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

avatar

@Shu

You answer have been of big help.

thank you very much