Class FlagFieldDataProcessor

  • All Implemented Interfaces:
    DocumentPreProcessor

    public class FlagFieldDataProcessor
    extends Object
    implements DocumentPreProcessor
    ConfigureableDataprocessor implementation which fills a flag field based on a pattern match in a source field. Will be auto configured and can be further configuration like described below:
     data-processor-configuration: 
       processors:
         - FlagFieldDataProcessor
      configuration:
        FlagFieldDataProcessor:
          # Multiple fields can be evaluated to flag one destination field.
          # Thus you must prefix your configuration with FlagFieldConfiguration.GROUP_PREFIX
          # the label after the prefix can be anything, import is though that they end with 
          # FlagFieldConfiguration.GROUP_SEPARATOR and that they have the same value for a group,
          # like the numeric values 1 and 2 below. For each field a match value can be provided by
          # appending FlagFieldConfiguration.FIELD_MATCH after the field name. Rules get evaluated
          # in order and as soon as one rule matches, the matching value is written into the flag field
          # and no further rules gets evaluated.
          group_1_title: \bfür\b\s+.+
          group_1_title_match: 0.9
          # Multiple regular expression can be provided separated by FlagFieldConfiguration.SEPARATOR
          group_1_category: \bzubeh(ö|oe)r\b##.*zubeh(ö|oe)r\b
          # If multiple regular expression are defined, multiple match values need to 
          # be provided as well. Every expression needs exactly one value.
          group_1_category_match: 1##0.8
          group_1_price: ^[\\d{,2}](\\.\\d)
          group_1_price_match: 0.3
          # One must provide a destination flag field per group by appending 
          # FlagFieldConfiguration.FIELD_FLAG_DESTINATION to the field name. 
          group_1_destination: "isAccessoire"
          # Optionally a no match value can by supplied which will be written into the destination
          # field if no rule within a group matched.
          group_1_noMatch: -1
          # Multiple groups are all evaluated, regardless if a previous group had a match or not.
          group_2_kpi: ".+"
          group_2_destination: "kpi"
          group_2_noMatch: 0
     
    • Constructor Detail

      • FlagFieldDataProcessor

        public FlagFieldDataProcessor()
    • Method Detail

      • initialize

        public void initialize​(FieldConfigAccess fieldConfig,
                               Map<String,​String> confMap)
        Description copied from interface: DocumentPreProcessor
        DataPreProcessor MUST have a no-args constructor. To configure it afterwards, this method will be used.
        Specified by:
        initialize in interface DocumentPreProcessor
        confMap - custom string-to-string map that can be configured per DocumentPreProcessor.
      • process

        public boolean process​(Document document,
                               boolean visible)
        Description copied from interface: DocumentPreProcessor
        Called for each source document.
        Specified by:
        process in interface DocumentPreProcessor
        visible - weather or not the record is currently marked for indexing.
        Returns:
        true if the record should be indexed, false otherwise.