Class LookupRecord

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.LookupRecord
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SideEffectFree @SupportsBatching @InputRequirement(INPUT_REQUIRED) @WritesAttribute(attribute="mime.type",description="Sets the mime.type attribute to the MIME Type specified by the Record Writer") @WritesAttribute(attribute="record.count",description="The number of records in the FlowFile") @Tags({"lookup","enrichment","route","record","csv","json","avro","database","db","logs","convert","filter"}) @CapabilityDescription("Extracts one or more fields from a Record and looks up a value for those fields in a LookupService. If a result is returned by the LookupService, that result is optionally added to the Record. In this case, the processor functions as an Enrichment processor. Regardless, the Record is then routed to either the \'matched\' relationship or \'unmatched\' relationship (if the \'Routing Strategy\' property is configured to do so), indicating whether or not a result was returned by the LookupService, allowing the processor to also function as a Routing processor. The \"coordinates\" to use for looking up a value in the Lookup Service are defined by adding a user-defined property. Each property that is added will have an entry added to a Map, where the name of the property becomes the Map Key and the value returned by the RecordPath becomes the value for that key. If multiple values are returned by the RecordPath, then the Record will be routed to the \'unmatched\' relationship (or \'success\', depending on the \'Routing Strategy\' property\'s configuration). If one or more fields match the Result RecordPath, all fields that match will be updated. If there is no match in the configured LookupService, then no fields will be updated. I.e., it will not overwrite an existing value in the Record with a null value. Please note, however, that if the results returned by the LookupService are not accounted for in your schema (specifically, the schema that is configured for your Record Writer) then the fields will not be written out to the FlowFile.") @DynamicProperty(name="Value To Lookup", value="Valid Record Path", expressionLanguageScope=FLOWFILE_ATTRIBUTES, description="A RecordPath that points to the field whose value will be looked up in the configured Lookup Service") @SeeAlso(value={ConvertRecord.class,SplitRecord.class}, classNames={"org.apache.nifi.lookup.SimpleKeyValueLookupService","org.apache.nifi.lookup.maxmind.IPLookupService","org.apache.nifi.lookup.db.DatabaseRecordLookupService"}) public class LookupRecord extends org.apache.nifi.processor.AbstractProcessor
  • Field Details

    • recordPathCache

      private final RecordPathCache recordPathCache
    • lookupService

      private volatile LookupService<?> lookupService
    • ROUTE_TO_SUCCESS

      static final org.apache.nifi.components.AllowableValue ROUTE_TO_SUCCESS
    • ROUTE_TO_MATCHED_UNMATCHED

      static final org.apache.nifi.components.AllowableValue ROUTE_TO_MATCHED_UNMATCHED
    • RESULT_ENTIRE_RECORD

      static final org.apache.nifi.components.AllowableValue RESULT_ENTIRE_RECORD
    • RESULT_RECORD_FIELDS

      static final org.apache.nifi.components.AllowableValue RESULT_RECORD_FIELDS
    • USE_PROPERTY

      static final org.apache.nifi.components.AllowableValue USE_PROPERTY
    • REPLACE_EXISTING_VALUES

      static final org.apache.nifi.components.AllowableValue REPLACE_EXISTING_VALUES
    • RECORD_READER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_READER
    • RECORD_WRITER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER
    • LOOKUP_SERVICE

      static final org.apache.nifi.components.PropertyDescriptor LOOKUP_SERVICE
    • ROOT_RECORD_PATH

      static final org.apache.nifi.components.PropertyDescriptor ROOT_RECORD_PATH
    • RESULT_CONTENTS

      static final org.apache.nifi.components.PropertyDescriptor RESULT_CONTENTS
    • ROUTING_STRATEGY

      static final org.apache.nifi.components.PropertyDescriptor ROUTING_STRATEGY
    • REPLACEMENT_STRATEGY

      static final org.apache.nifi.components.PropertyDescriptor REPLACEMENT_STRATEGY
    • RESULT_RECORD_PATH

      static final org.apache.nifi.components.PropertyDescriptor RESULT_RECORD_PATH
    • CACHE_SIZE

      static final org.apache.nifi.components.PropertyDescriptor CACHE_SIZE
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_MATCHED

      static final org.apache.nifi.processor.Relationship REL_MATCHED
    • REL_UNMATCHED

      static final org.apache.nifi.processor.Relationship REL_UNMATCHED
    • REL_SUCCESS

      static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • REL_FAILURE

      static final org.apache.nifi.processor.Relationship REL_FAILURE
    • MATCHED_COLLECTION

      private static final Set<org.apache.nifi.processor.Relationship> MATCHED_COLLECTION
    • UNMATCHED_COLLECTION

      private static final Set<org.apache.nifi.processor.Relationship> UNMATCHED_COLLECTION
    • SUCCESS_COLLECTION

      private static final Set<org.apache.nifi.processor.Relationship> SUCCESS_COLLECTION
    • relationships

      private volatile Set<org.apache.nifi.processor.Relationship> relationships
    • routeToMatchedUnmatched

      private volatile boolean routeToMatchedUnmatched
  • Constructor Details

    • LookupRecord

      public LookupRecord()
  • Method Details

    • onScheduled

      @OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context)
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getSupportedDynamicPropertyDescriptor

      protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
      Overrides:
      getSupportedDynamicPropertyDescriptor in class org.apache.nifi.components.AbstractConfigurableComponent
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • onPropertyModified

      public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
      Specified by:
      onPropertyModified in interface org.apache.nifi.components.ConfigurableComponent
      Overrides:
      onPropertyModified in class org.apache.nifi.components.AbstractConfigurableComponent
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • getSubRecords

      private List<Record> getSubRecords(Record record, RecordPath rootRecordPath)
    • getRelationships

      private Set<org.apache.nifi.processor.Relationship> getRelationships(Set<LookupRecord.MatchResult> matchResults)
    • createReplacementStrategy

      private LookupRecord.ReplacementStrategy createReplacementStrategy(org.apache.nifi.processor.ProcessContext context)
    • createLookupContext

      protected LookupRecord.LookupContext createLookupContext(org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, RecordSetWriterFactory writerFactory)