NiFi:ReplaceTextWithMapping处理器 [英] NiFi: ReplaceTextWithMapping processor

查看:351
本文介绍了NiFi:ReplaceTextWithMapping处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下插入语句:

  1. insert into temp1 values (test1, test2)

insert into temp2 values (test3)

预期结果:

  1. insert into temp1 values (100, 200)

insert into temp2 values (300)

本质上,我想分别用值100200替换第一个查询文字test1test2,对于第二个查询,用值300替换test3.有人可以为上述用例提供映射文件帮助吗?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆