Skip to main content

ForceSingleValueTransformer

Forces a metadata field to be single-value

Notes

The action can be one of the following:

  • keepFirst: Keeps the first occurrence found.
  • keepLast: Keeps the last occurrence found.
  • mergeWith:<sep>: Merges all values into one, separated by <sep>..

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

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

Examples

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

handler:
class: ExternalParser
action: keepFirst
fieldMatcher:
pattern: title

Usage

Full configuration skeleton, with every option and its default
class: ForceSingleValueTransformer
action: string
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
label: string

Properties

PropertyTypeRequiredDefault
actionstringNo-
fieldMatcherTextMatcherNoTextMatcher
labelstringNo-

Property Details

action

The action can be one of the following:

"action"="[keepFirst|keepLast|mergeWith:separator]"

  • keepFirst: Keeps the first occurrence found.
  • keepLast: Keeps the last occurrence found.
  • mergeWith:<sep>: Merges all values into one, separated by <sep>..

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

fieldMatcher

Matches document fields based on specified patterns and methods

label

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.