Class ForceSingleValueTagger

  • All Implemented Interfaces:
    IXMLConfigurable, IImporterHandler, IDocumentTagger

    public class ForceSingleValueTagger
    extends AbstractDocumentTagger

    Forces a metadata field to be single-value. The action can be one of the following:

    Can be used both as a pre-parse or post-parse handler.

        keepFirst          Keeps the first occurrence found.
        keepLast           Keeps the first occurrence found.
        mergeWith:<sep>    Merges all occurrences, joining them with the
                           specified separator (<sep>).
     

    If you do not specify any action, the default behavior is to merge all occurrences, joining values with a comma.

    XML configuration usage:

    
    <handler
        class="com.norconex.importer.handler.tagger.impl.ForceSingleValueTagger"
        action="[keepFirst|keepLast|mergeWith:separator]">
      <!-- multiple "restrictTo" tags allowed (only one needs to match) -->
      <restrictTo>
        <fieldMatcher>(field-matching expression)</fieldMatcher>
        <valueMatcher>(value-matching expression)</valueMatcher>
      </restrictTo>
      <fieldMatcher>
        (one or more matching fields to force having a single value)
      </fieldMatcher>
    </handler>

    XML usage example:

    
    <handler
        class="ForceSingleValueTagger"
        action="keepFirst">
      <fieldMatcher>title</fieldMatcher>
    </handler>

    For documents where multiple title fields are found, the above only keeps the first title value captured.

    Author:
    Pascal Essiembre