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

查看:901
本文介绍了在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:

所需流:

attribute:    
xuuid = 123456

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

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

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将数千个json消息合并到一个流文件中.

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