Hello, So I dove into ReplaceTextWithMapping to try and get it to solve your use-case but I just don't think it is powerful enough to do what you want. Currently it is designed almost solely for the purpose: match a simple regex, map one group of non-whitespace characters to another group of characters (can have white space and back references).
When looking at your use-case as pure text, it is to change the value of one capture group based on the value of another capture group and a mapping file. Looking at it in terms of JSON, your use-case is much simpler, you want to change the value of a key/value pair based on what the key is and a mapping file. Side note, if you didn't need the mapping file, I believe there is a new JSON to JSON processor coming in 0.7.0[1] that would work. As for looking for a solution, both ways of looking at your problem are valid. ReplaceTextWithMapping certainly could use expanded functionality to allow for advanced use-cases but may make it too complicated (though it could be more confusing now due to the unclear scope of it's functionality). A new processor, along the lines of "ReplaceJsonWithMapping" could certainly be added as well but would need to clearly define it's scope and purpose. Does anyone have thoughts on this use-case? Also if anyone has more experience with ReplaceTextWithMapping, please feel free to correct me. [1] https://issues.apache.org/jira/browse/NIFI-1850 Joe - - - - - - Joseph Percivall linkedin.com/in/Percivall e: [email protected] On Sunday, May 15, 2016 3:09 PM, idioma <[email protected]> wrote: 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.
