以下是一个使用Apache Nifi的UpdateRecord处理器来替换子值的示例代码:
首先,你需要创建一个UpdateRecord处理器,并将其配置为使用RecordPath和ReplacementValue进行子值替换。假设你想要将JSON数据中的"name"字段值替换为"new_name",你可以按照以下步骤进行配置:
完成配置后,你可以将输入数据流连接到UpdateRecord处理器,并将处理结果发送到下一个处理器或输出流。
以下是一个基于Apache Nifi的示例代码:
Apache Nifi: UpdateRecord Replace Subvalue
Example template for replacing subvalue using UpdateRecord processor
org.apache.nifi
apache-nifi-templates
1.10.0
1.0
1e7e9c5b-3f8c-31ca-b5f7-1345e1f2e1ed
root
250.0
250.0
org.apache.nifi
apache-nifi-update-record-processors
1.10.0
Replacement Value Strategy
Record Path Value
record.path
/name
record.value
new_name
Replacement Value Strategy
Replacement Value Strategy
Replacement Value Strategy
The strategy for handling the replacement value.
Literal Value
Literal Value
The replacement value is a literal value.
Record Path Value
Record Path Value
The replacement value is determined by evaluating a RecordPath expression against the current record.
Literal Value
true
false
false
true
record.path
record.path
record.path
The path to the field or sub-field to update. Supports evaluating against nested fields using dot-notation.
true
false
false
true
record.value
record.value
record.value
The value to update the field or sub-field to.
true
false
false