Floor
Synopsis
Calculates the floor function of numeric values, returning the largest integer that is less than or equal to the input value.
Schema
- floor:
description: <text>
field: <ident>
value: <string>
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 | Field to store the floor result | |
value | Y | Numeric value or field reference to calculate floor for | |
description | N | - | Explanatory notes |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | Continue processing if referenced fields are missing |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor applies the mathematical floor function to numeric values. The floor function returns the largest integer that is less than or equal to the input value. For example:
floor(3.7)
= 3floor(-2.3)
= -3floor(5.0)
= 5floor(-1.0)
= -1
The value
parameter can be either a literal numeric value or a field reference. When using field references, the processor will resolve the field value and apply the floor operation to it.
The floor function is commonly used in data processing for grouping continuous values into discrete buckets, time-based calculations, and normalization operations.
For negative numbers, the floor function rounds towards negative infinity, not towards zero. This means floor(-2.3)
equals -3, not -2.
Use the floor processor in combination with mathematical operations to create time-based groupings, such as rounding timestamps to the nearest hour or creating histogram buckets.
Examples
Basic Floor Operation
Calculate the floor of a decimal value... |
|
to get the integer part: |
|
Negative Number Floor
Floor of negative numbers... |
|
rounds towards negative infinity: |
|
Time Bucket Creation
Create hourly time buckets... |
|
for time-based grouping: |
|
Literal Values
Use literal numeric values... |
|
for constant calculations: |
|
Score Normalization
Normalize scores to integer ranges... |
|
for categorical grouping: |
|
Percentage Buckets
Create percentage buckets... |
|
for progress tracking: |
|
In-Place Modification
Modify the original field... |
|
by using the same field name: |
|
Complex Expressions
Use complex mathematical expressions... |
|
for advanced calculations: |
|
Zero and Integer Values
Floor of integers and zero... |
|
remain unchanged: |
|