java 根据 NiFi 中的内容更新属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38910721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Update attributes based on content in NiFi
提问by Lasitha Yapa
How can I add a attribute to the current flow file when developing an Apache NiFi cusom processor.
What I want to do is adding a new attribute (or at least update a current attribute) to the current flow file with calculated value.
Or is there an already built processor that I can use?
在开发 Apache NiFi cusom 处理器时,如何向当前流文件添加属性。
我想要做的是使用计算值向当前流文件添加新属性(或至少更新当前属性)。
或者是否有我可以使用的已经构建的处理器?
回答by James
NiFi supports several methods of creating and updating attributes, depending on the data source you wish to use. Some general purpose processors include:
NiFi 支持多种创建和更新属性的方法,具体取决于您希望使用的数据源。一些通用处理器包括:
UpdateAttribute- Updates attributes on flow files using both static values and NiFi's expression language.
UpdateAttribute- 使用静态值和 NiFi 的表达式语言更新流文件的属性。
You can add as many properties with one processor. I recommend scanning through the Apache NiFi Expression Language Guideto get a feel for what you can do with it.
您可以使用一个处理器添加尽可能多的属性。我建议您浏览Apache NiFi 表达式语言指南,以了解您可以使用它做什么。
ExtractText- The Sets attribute values by applying regular expressions to the flowfile content.
ExtractText- 通过将正则表达式应用于流文件内容来设置属性值。
ExecuteScript- ExecuteScript Runs custom script code, which can be used to update attributes however you wish.
ExecuteScript- ExecuteScript 运行自定义脚本代码,可用于根据需要更新属性。
And there are more for particular content formats, for example:
还有更多针对特定内容格式的内容,例如:
- EvaluateJsonPath- for JSON
- EvaluateXPath- for XML
- EvaluateJsonPath- 用于 JSON
- EvaluateXPath- 用于 XML