CopyTransformer
Copies metadata fields to new fields
Notes
This functionality duplicates the value(s) of one or more document fields (or metadata) into other fields. It is useful for retaining original data while making modifications, or for mapping data to new fields during processing.
Storing values in an existing field
If a document already has a target field with the same name,
new values are appended to the existing list by default. Use onSet to manage this default behavior.
The root-level onSet applies to all operations, while fieldMatcher-level onSet overrides the behavior for specific fields.
Parser Handler Compatibility
This functionality can be applied as either a pre-parse or post-parse handler.
Examples
The following example copies the value of a "creator" and "publisher" fields into an "author" field, adding to any existing values in the "author" field.
- YAML
- JSON
- XML
handler:
class: CopyTransformer
operations:
- toField: author
onSet: APPEND
fieldMatcher:
method: REGEX
pattern: (creator|publisher)
{
"handler": {
"class": "CopyTransformer",
"operations": [
{
"toField": "author",
"onSet": "APPEND",
"fieldMatcher": {
"method": "REGEX",
"pattern": "(creator|publisher)"
}
}
]
}
}
<handler>
<class>CopyTransformer</class>
<operations>
<op>
<toField>author</toField>
<onSet>APPEND</onSet>
<fieldMatcher>
<method>REGEX</method>
<pattern>(creator|publisher)</pattern>
</fieldMatcher>
</op>
</operations>
</handler>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: CopyTransformer
label: string
onSet: APPEND
operations:
- fieldMatcher: {}
onSet: APPEND
toField: string
{
"class": "CopyTransformer",
"label": "string",
"onSet": "APPEND",
"operations": [
{
"fieldMatcher": {},
"onSet": "APPEND",
"toField": "string"
}
]
}
<handler>
<class>CopyTransformer</class>
<label>string</label>
<onSet>APPEND</onSet>
<operations>
<op>
<fieldMatcher/>
<onSet>APPEND</onSet>
<toField>string</toField>
</op>
</operations>
</handler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
label | string | No | - |
onSet | enum | No | - |
operations | CopyOperation[] | 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.
onSet
Defines what to do when the target field already has one or more values. When unspecified, new values are appended to existing ones by default.
Allowed Values
APPENDPREPENDREPLACEOPTIONAL
operations
Allows defining multiple operations as a list.