在 NiFi 中将两个 JSON 流文件合并在一起 [英] Merge two JSON flowfile together in NiFi

查看:66
本文介绍了在 NiFi 中将两个 JSON 流文件合并在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想合并两个包含相同指定属性的 JSON 对象的流文件...

i want to merge two flowfile that contain JSON object by same specified attribute...

流程 1:

attribute:    
xuuid = 123456

content:
{
"sname":"jack",
"id":"00001",
"state":"NY"
}

流程 2:

attribute:    
xuuid = 123456

content:
{
"country":"US",
"date":"1983"
}

我希望在单个输出流中使用这种形式的数据:

and i expect this form of data in single output flow:

desired_flow:

attribute:    
xuuid = 123456

content:
{
"sname":"jack",
"id":"00001",
"state":"NY",
"country":"US",
"date":"1983"
}

我怎么玩这个?MergeContent 处理器还是 MergeRecord?我认为 mergeecord 可以处理它,但我对此感到困惑.

how do i play with this? MergeContent processor or MergeRecord? i think mergerecord can handle it but i confusing on it.

推荐答案

您要求的是流式连接,这不是 NiFi 真正做的事情,这里有类似的问题和答案:

What you are asking for is a streaming join and it is not something that NiFi really does, similar question and answer here:

https://stackoverflow.com/a/42909221/5650316

合并处理器是为了一个接一个地合并数据块,而不是执行流式连接.例如,如果您有许多小的 json 消息,您可能希望在写入 HDFS 之前使用 MergeContent 或 MergeRecord 将数千条消息合并到一个流文件中.

The merge processors are made to merge pieces of data one after another, not to perform a streaming join. For example, if you have many small json messages you would want to use MergeContent or MergeRecord to merge together thousands of them into a single flow file before writing to HDFS.

这篇关于在 NiFi 中将两个 JSON 流文件合并在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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