删除 NiFi 中的空属性 [英] Delete empty attributes in NiFi

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

问题描述

由于这个问题仍未解决,我有一个EvaluateJsonPath 处理器,有时会输出带有空字符串的属性.

Because of this issue being still unresolved, I have an EvaluateJsonPath processor that sometimes outputs attributes with empty strings.

是否有一种直接的方法可以从流文件中删除属性?

Is there a straight-forward way to delete attributes from a flowfile?

我尝试使用 UpdateAttributes 处理器,但它只能根据匹配属性名称进行删除(我需要匹配属性值).

I tried using the UpdateAttributes processor, but it only is able to delete based on matching an attribute's name (I need to match on the attribute's value).

推荐答案

您可以使用带有以下代码的 ExecuteGroovyScript 1.5.0 处理器:

you can use ExecuteGroovyScript 1.5.0 processor with the following code:

def ff=session.get()
if(!ff)return
def emptyKeys = ff.getAttributes().findAll{it.value==null || it.value==''}.collect{it.key}
ff.removeAllAttributes(emptyKeys)
REL_SUCCESS<<ff

这篇关于删除 NiFi 中的空属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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