ConstantTransformer
Define and add constant values to documents.
Notesโ
To add multiple constant values under the same constant name, repeat the constant entry with a different value.
onSet property determines how constant values are applied to fields that may already exist in a document. It can be configured globally (at the root of the handler) or individually for each constant
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.
Parser Handler Compatibilityโ
This functionality can be applied as either a pre-parse or post-parse handler.
Examplesโ
The following example adds a constant to incoming documents to identify they were web and mobile documents plus a constant number
- YAML
- JSON
- XML
handler:
class: ConstantTransformer
constants:
- name: source
values:
- web
- mobile
- name: limit
values:
- "3"
{
"handler": {
"class": "ConstantTransformer",
"constants": [
{
"name": "source",
"values": [
"web",
"mobile"
]
},
{
"name": "limit",
"values": [
"3"
]
}
]
}
}
<handler>
<class>ConstantTransformer</class>
<constants>
<constant>
<name>source</name>
<values>
<value>web</value>
<value>mobile</value>
</values>
</constant>
<constant>
<name>limit</name>
<values>
<value>3</value>
</values>
</constant>
</constants>
</handler>
Usageโ
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: ConstantTransformer
constants:
- name: string
onSet: APPEND
values: []
label: string
onSet: APPEND
{
"class": "ConstantTransformer",
"constants": [
{
"name": "string",
"onSet": "APPEND",
"values": []
}
],
"label": "string",
"onSet": "APPEND"
}
<handler>
<class>ConstantTransformer</class>
<constants>
<constant>
<name>string</name>
<onSet>APPEND</onSet>
<values>
<value/>
</values>
</constant>
</constants>
<label>string</label>
<onSet>APPEND</onSet>
</handler>
Propertiesโ
| Property | Type | Required | Default |
|---|---|---|---|
constants | Constant[] | No | - |
label | string | No | - |
onSet | enum | No | - |
Property Detailsโ
constantsโ
Manage the constants list
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โ
What to do if a target field of the same name already exist.
Allowed Valuesโ
APPENDPREPENDREPLACEOPTIONAL