NiFi:ReplaceTextWithMapping 处理器 [英] NiFi: ReplaceTextWithMapping processor
问题描述
我有以下插入语句:
插入 temp1 值 (test1, test2)
插入 temp2 值 (test3)
预期结果:
插入 temp1 值 (100, 200)
插入 temp2 值 (300)
本质上,我想分别用值 100
、200
替换第一个查询文字 test1
、test2
对于第二个查询,将 test3
替换为值 300
.有人可以帮助上述用例的映射文件吗?
Essentially, I wanted to replace the first query literals test1
, test2
with value 100
, 200
respectively and for the second query replace test3
with value 300
. Can someone help with the mapping file for the above use case?
我尝试了以下方法,但没有任何效果.
I tried with the following, but it doesn't have any effect.
搜索值 (RegEx) 替换值
Search Value (RegEx) Replacement values
(1)(.*values.*)(.*test1)(.*,)(.*test2) -> $2 val1 $4 val2
(2)(.*values.*)(.*test1) -> $2 val3
推荐答案
如果这确实是您需要执行的映射范围,那么常规的 ReplaceText
处理器就足够了.使用以下设置会产生所需的输出:
If this is literally the extent of the mapping you need to perform, a regular ReplaceText
processor is enough. Using the settings below results in the desired output:
它只是检测 test
的每个实例后跟一个数字,并用该数字和 00
替换它.
It simply detects every instance of test
followed by a single digit and replaces it with that digit and 00
.
如果您需要使用 ReplaceTextWithMapping
进行更复杂的查找,映射文件必须采用以下格式:
If you need to use ReplaceTextWithMapping
for more complex lookups, the mapping file must be of the format:
search_value_1 replacement_value_1
search_value_2 replacement_value_2
etc.
搜索值和替换值之间的分隔符是 \t.
The delimiter between the search and replacement values is \t.
--------------------------------------------------
Standard FlowFile Attributes
Key: 'entryDate'
Value: 'Wed Dec 07 10:48:24 PST 2016'
Key: 'lineageStartDate'
Value: 'Wed Dec 07 10:48:24 PST 2016'
Key: 'fileSize'
Value: '66'
FlowFile Attribute Map Content
Key: 'filename'
Value: '56196144045589'
Key: 'path'
Value: './'
Key: 'uuid'
Value: 'f6b28eb0-73b5-4d94-86c2-b7a5d4cc991e'
--------------------------------------------------
insert into temp1 values (100, 200)
insert into temp2 values (300)
这篇关于NiFi:ReplaceTextWithMapping 处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!