Class CaptureGroupMetadataFilter

All Implemented Interfaces:
Closeable, Serializable, AutoCloseable, Initializable

public class CaptureGroupMetadataFilter extends MetadataFilterBase implements Initializable
This filter runs a regex against the first value in the "sourceField". If the pattern matches, it extracts the first group of the first match and set's the "targetField"'s value to that first group.

If there is a match, this will overwrite whatever value is in the "targetField".

If there is not a match, this filter will be a no-op.

If there are multiple matches, this filter will capture only the first. Open a ticket if you need different behavior.

If the source field has multiple values, this will run the regex against only the first value.

If the source field does not exist, this filter will be a no-op.

If the target field is the same value as the source field, this filter will overwrite the value in that field. Again, if there are multiple values in that field, those will all be overwritten.

See Also:
  • Constructor Details

  • Method Details

    • filter

      protected void filter(Metadata metadata)
      Specified by:
      filter in class MetadataFilterBase
    • setRegex

      public void setRegex(String regex)
    • setSourceField

      public void setSourceField(String sourceField)
    • setTargetField

      public void setTargetField(String targetField)
    • getRegex

      public String getRegex()
    • getSourceField

      public String getSourceField()
    • getTargetField

      public String getTargetField()
    • initialize

      public void initialize() throws TikaConfigException
      Description copied from interface: Initializable
      Called after all properties have been set to allow for validation and initialization that depends on multiple properties.
      Specified by:
      initialize in interface Initializable
      Throws:
      TikaConfigException - if there is a problem with the configuration