Reverse
Synopsis
Reverses the order of a field's contents: the characters of a string, or the elements of an array.
Schema
- reverse:
field: <ident>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
target_field: <ident>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Field to reverse. Must hold a string or an array |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | If true, quietly exit if field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
target_field | N | field | Field to store the reversed value. Defaults to field, reversing in place |
Details
A string is reversed by character, not by byte, so multi-byte text survives the operation intact. An array is reversed by element; the elements themselves are untouched, including nested objects and arrays.
Any other value — a number, an object, a boolean — is an error. There is no meaningful element order to reverse.
The reversed value is built as a new value rather than being rearranged in place, so a target_field that differs from field leaves the source exactly as it was.
Examples
Reversing a String
Reversing the characters of a string... | |
which is the form domain lookups often index on: | |
Reversing an Array
Reversing element order, newest event first... | |
in place, since no | |
Non-ASCII Text
Reversal is by character, so accented and non-Latin text is not corrupted... | |
and the accented character survives: | |