I have been trying to understand how to use ReplaceTextWithMapping in a
specific case where I would like to substitute the same input value with
different mapping values depending on the matching group.
My input file looks like this (this is only an excerpt):
{"field1" : "A",
"field2" : "A",
"field3": "A"
}
The mapping file looks like this:
Header1;Header2;Header3
A;some text;2
My expected result would be as follows:
{"field1" : "some text",
"field2": "A",
"field3": "A2"
}
The Regular Expression set is simply as follows:
[A-Z0-9]+
and it matches the field key in the mapping file (we are expecting either a
capital letter or capital letter + digit), but then I am not sure how you
decide to which value (from col 1 or from col3) you want to assign the input
value to. Specifically, although the value for field2 matches the regex, I
do not want the substitution to happen, instead I will need to preserve the
original value in the input file (I am not sure if this is possible). At the
moment, I am getting something like this:
{"field1" : "some text A2",
"field2": "some text A2",
"field3": "some text A2"
}
I guess my main question is: can you map the same value in your input file
to different values coming from different columns of your mapping file? Can
you ignore the mapping, although the regex matches the input value? (for
example, field 2). Can you have multiple values in the Matching group
property?
Thank you so much for your help. This has been troubling me for a while and
I do not seem to find a solution to it.
--
View this message in context:
http://apache-nifi-developer-list.39713.n7.nabble.com/Help-with-ReplaceTextWithMapping-processor-multi-column-mappings-tp10280.html
Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.