Skip to main content

EnrichAttributes

Description

Looks up a value using the configured Lookup Service and adds the results to the FlowFile as one or more attributes. Frequently, this is used in conjunction with the DatabaseLookup Service in order to enrich a FlowFile by querying a database and adding the results as attributes.

Tags

attributes, database, datavolo, enrichment, json, lookup

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Lookup Service *Lookup ServiceController Service:
RecordLookupService

Implementations:
CSVRecordLookupService
DatabaseLookup
DatabaseRecordLookupService
IPLookupService
RestLookupService
The Lookup Service to use for enrichment
Flattening Strategy *Flattening StrategyFlatten Recursively
  • Flatten Initial Level
  • Flatten Recursively
  • Do Not Flatten
When a Record is returned from the Lookup Service, this property specifies how the Record should be flattened into the FlowFile's attributes
Attribute Name *Attribute NamerecordThe name of the attribute to add, whose contents will be the JSON representation of the Record returned from the Lookup Service.

This property is only considered if:
  • the property Flattening Strategy has a value of Do Not Flatten
Attribute PrefixAttribute PrefixA prefix to apply to all attribute names that are added.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Flattening Strategy has a value of Flatten Recursively or Flatten Initial Level

Dynamic Properties

NameValueDescription
<The name of a variable to pass to the Lookup Service><The value of the variable to pass to the Lookup Service>If one or more dynamic properties are specified, the values will be used to provide Lookup Coordinates / variables to the configured LookupService in order to determine the value to look up. If no dynamic properties are specified, the FlowFile's attributes will be used as the Lookup Coordinates.

Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables.

Relationships

NameDescription
failureIf unable to enrich a given FlowFile for any reason, the FlowFile will be routed to this relationship.
matchedFlowFiles that are successfully enriched with the Record from the Lookup Service are routed to this relationship.
unmatchedFlowFiles for which the Lookup Service did not find a match are routed to this relationship.

Reads Attributes

This processor does not read attributes.

Writes Attributes

This processor does not write attributes.

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

Example Use Cases

Use Case 1

Query a database to retrieve information based on the attributes of a FlowFile

Configuration

Configure the DatabaseLookup service with the appropriate Connection Pooling Service for connecting to the database.
Configure 'SQL' property of the DatabaseLookup Service to specify the SQL query to execute. The SQL query can reference FlowFile attributes using the Expression Language.

Set the 'Lookup Service' property to reference the DatabaseLookup service.
Set the 'Flattening Strategy' property to a value of 'Flatten Initial Level'.

For example, if a FlowFile has an attribute named 'customer_id' and the desire is to retrieve the 'FIRST_NAME', 'LAST_NAME', and 'EMAIL_ADDRESS' fields from a database, the
DatabaseLookup service would be configured with a SQL query such as SELECT FIRST_NAME, LAST_NAME, EMAIL_ADDRESS FROM CUSTOMERS WHERE CUSTOMER_ID = $\{customer_id}.
There is no need to worry about SQL injection attacks, as the DatabaseLookup service will properly parameterize the query in order to prevent such attacks.

System Resource Considerations

This component does not specify system resource considerations.

See Also

DatabaseLookupService