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.

How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

Solved Go to solution

How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

New Contributor

I am looking for a simple example of how to use the NiFi ReplaceTextWithMapping to parse file contents. Are templates available including a mapping file? Please share.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

Guru

@Kausha Simpson

ReplaceTextWithMapping works exactly like ReplaceText with the exception that the ReplaceText property "Replacement Value" is defined in an external file. Unfortunately the format of that file is not very well documented. I have attached an example of that file and a sample workflow but for a high level overview the mapping file format is newline delimited per mapping defined with a \t character separator the mapping key to the desired replacement value. Good luck and hope this information helps.

5 REPLIES 5

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

Mentor
@Kausha Simpson

quick search on the templates github repo shows 0 results. @jpercivall any help?

Highlighted

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

Guru

@Kausha Simpson

ReplaceTextWithMapping works exactly like ReplaceText with the exception that the ReplaceText property "Replacement Value" is defined in an external file. Unfortunately the format of that file is not very well documented. I have attached an example of that file and a sample workflow but for a high level overview the mapping file format is newline delimited per mapping defined with a \t character separator the mapping key to the desired replacement value. Good luck and hope this information helps.

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

New Contributor

@Jeremy Dyer, thanks again!

This is a good starting point. It seems that the mapping requires a 1-to-1 relationship and might not permit more dynamic programming. I'll continue to research this processor as well as options for ExecuteProcess.

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

Hey Jeremy, just a heads up I just added your template and mapping file to the HWX NiFi Template repo @Artem Ervits mentioned (https://github.com/hortonworks-gallery/nifi-templates)

Re: How are mapping files formatted for the NiFi ReplaceTextWithMapping processor?

New Contributor

@Jeremy Dyer I understand how a global replacement works, but am struggling when I just want to replace certain occurrences.

Let's say my Flowfile looks like this:

xyz key=AABBBBCC foo bar AABBBBCC

Another one looks like this:

xyz key=DDEEEEFF foo bar DDEEEEFF

I only want to replace the values that are prepended by key=

I tried with Regular Expression key=(\S+) and Matching Group 1 , which didn't work.

What did work was setting the Regex to key=(AABBBBCC|DDEEEEFF), but this unfortunately makes the regex static.