Skip to main content

MergeTransformer

Merge multiple metadata fields into a single one.

Notes

Each entry under operations selects source fields with a fieldMatcher and writes their combined values to toField.

By default every value is added to the target field, making it multi-valued. Set singleValue to true to combine them into one string instead, joined by singleValueSeparator — or by nothing at all if no separator is given.

Set deleteFromFields to true to remove the source fields once merged. The target field may itself be one of the source fields: its content is then replaced by the merged result, and it survives even with deleteFromFields enabled.

When the matcher finds only one field, its values are copied to the target and still collapsed to a single value if configured to. That makes this handler an alternative to ForceSingleValueTransformer with a mergeWith action.

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

Examples

The following example merges several title fields into one, joining multiple occurrences with a coma, and deleting original fields.

handler:
class: MergeTransformer
operations:
- toField: title
deleteFromFields: true
singleValue: true
singleValueSeparator: ","
fieldMatcher:
method: REGEX
pattern: (title|dc.title|dc:title|doctitle)

Usage

Full configuration skeleton, with every option and its default
class: MergeTransformer
label: string
operations:
- deleteFromFields: false
fieldMatcher: {}
singleValue: false
singleValueSeparator: string
toField: string

Properties

PropertyTypeRequiredDefault
labelstringNo-
operationsMergeOperation[]No-

Property Details

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.

operations

One or more merges to perform, each naming the fields to merge, the field to merge them into, and whether to collapse the result to a single value. See MergeOperation.