Add
Adds two numeric values and stores the result in a field.
Schema
- add:
field: <ident>
left_operand: <string>
right_operand: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Target field to store the addition result |
left_operand | Y | - | First operand in the addition (numeric literal or field reference) |
right_operand | Y | - | Second operand in the addition (numeric literal or field reference) |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if calculation fails |
ignore_missing | N | false | Use 0 for missing fields instead of failing |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Adds two numeric values and stores the result in a specified field. This processor supports arithmetic addition between numeric literals, field values, or a combination of both.
The processor automatically converts string representations of numbers to their numeric values before performing addition. This makes it flexible when working with different data types or values extracted from text fields.
The processor evaluates both operands, performs the addition operation, and sets the result in the target field. If operand fields don't exist and ignore_missing
is enabled, the processor will substitute a value of 0 for the missing field.
If either operand cannot be converted to a number, the processor will fail unless ignore_failure
is set to true
. For missing fields, use ignore_missing: true
to substitute zeros instead of failing.
Examples
Basic
Adding two numeric values... |
|
stores the result in a new field: |
|
Using Literals
Adding a field value to a constant... |
|
adds the constant to the field value: |
|
In-Place
Incrementing a field's value... |
|
updates the existing field: |
|
Handling Missing Fields
Adding with missing field protection... |
|
treats missing fields as zero: |
|
Nested Fields
Adding values from nested fields... |
|
stores result in a nested field: |
|