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