Abs
Synopsis
Returns the absolute value of a numeric field.
Schema
- abs:
field: <ident>
value: <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 absolute value result |
value | Y | - | Source value or field reference to calculate absolute value from |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if calculation fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Calculates the absolute value of a numeric value and assigns the result to the specified field. This processor converts negative numbers to their positive equivalents while keeping positive numbers unchanged.
The processor will automatically convert string representations of numbers to their numeric values before calculating the absolute value. This makes it flexible when working with different data types.
The processor can evaluate numeric values from a field reference or a numeric literal. It handles various numeric types and ensures that the result is always a positive number.
If the specified value or referenced field cannot be converted to a number, the processor will fail unless ignore_failure
is set to true
. Always ensure that the input value is numeric or can be parsed as a number.
Examples
Basic
Calculating absolute value from a negative number... |
|
creates a new field with absolute value: |
|
In-Place
Replacing field value with its absolute value... |
|
overwrites the original value: |
|
Using Literals
Calculating absolute value from a literal... |
|
sets field to the absolute value: |
|
Conditionals
Calculating absolute value only when needed... |
|
processes conditionally: |
|