Skip to main content

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

handler:
class: ConstantTransformer
constants:
- name: source
values:
- web
- mobile
- name: limit
values:
- "3"

Usageโ€‹

Full configuration skeleton, with every option and its default
class: ConstantTransformer
constants:
- name: string
onSet: APPEND
values: []
label: string
onSet: APPEND

Propertiesโ€‹

PropertyTypeRequiredDefault
constantsConstant[]No-
labelstringNo-
onSetenumNo-

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โ€‹

  • APPEND
  • PREPEND
  • REPLACE
  • OPTIONAL