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

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

问题描述

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

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天全站免登陆