本文介绍了使用apache-nifi将值替换为流文件中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用流文件中分配的变量替换值.

I am trying to replace a value with a variable assigned in flowfile.

在我的流文件中,我已将flowID分配给flow_id变量.

In my flowfile, I have assigned flowID to flow_id variable.

UpdateRecord处理器中,我尝试更新名为/flow的列,该列具有INFLOWOUTFLOW,我将其作为${field.value:replaceAll('INFLOW',$flow_id)}

In UpdateRecord processor, I try to update a column named /flow which has INFLOW and OUTFLOW I have following as ${field.value:replaceAll('INFLOW',$flow_id)}

UpdateRecord之前的流文件:

id,flow,flow_id
1,INFLOW,IN
2,OUTFLOW,OUT
3,INFLOW,IN

转换后的流文件应为:

id,flow,flow_id
1,IN,IN
2,OUT,OUT
3,IN,IN

但是失败并显示错误

回答和评论后

现在我有以下设置:

${field.value:replace('INFLOW',flow_id)}

Literal ValueRecord path value替换策略出现相同的错误.

Same error for Literal Value and Record path value Replacement strategies.

推荐答案

设置Nifi工作流程,如下所示:

GetFile处理器中设置input directory.在第一个UpdateRecord处理器中,将flowflow_id列连接起来,并将其分配给flow.通过更改 First UpdateRecord处理器的配置,如下所示.

Set your input directory in the GetFile Processor. In the first UpdateRecord Processor concatenate the flow and flow_id columns and assign it into flow. Do this by changing the configurations of the First UpdateRecord processor as shown below.

下一个UpdateRecord处理器将相应地替换INFLOWOUTFLOW.设置第二 UpdateRecord处理器的配置,如下所示.

The next UpdateRecord Processor replaces INFLOW and OUTFLOW accordingly. Set the configurations of the second UpdateRecord Processor as shown below.

由于初始缩略",被添加到流列中.我已使用其他两个处理器将其删除.

Because of the initial concating " and , is added in the flow column. I have used the other two processors to remove them.

第三 UpdateRecord处理器必须具有一个名为/flow的新属性,并具有值${field.value:replaceFirst(${field.value:substringAfter(',')},'')}.其余配置保留为第二 UpdateRecord处理器.

The third UpdateRecord Processor must have a new property named /flow and have the value ${field.value:replaceFirst(${field.value:substringAfter(',')},'')}. The rest of the configurations remain as the Second UpdateRecord Processor.

第四 UpdateRecord处理器必须具有一个名为/flow的新属性,并具有值${field.value:replaceFirst('"',''):replaceFirst(',','')}.其余配置保留为第二 UpdateRecord处理器.

The Fourth UpdateRecord Processor must have a new property named /flow and have the value ${field.value:replaceFirst('"',''):replaceFirst(',','')}. The rest of the configurations remain as the Second UpdateRecord Processor.

注意:该答案是 基于.

这篇关于使用apache-nifi将值替换为流文件中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 02:20