Skip to main content
Version: 1.3.0

Split

Mutate Elastic Compatible

Synopsis​

Splits a string field into an array using a specified separator pattern.

Schema​

- split:
field: <ident>
separator: <char>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
preserve_trailing: <boolean>
tag: <string>
target_field: <ident>

Configuration​

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Field containing the string to split
separatorY-Character or regular expression pattern to use as separator
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseSee Handling Failures
ignore_missingNfalseIf true, quietly exit if field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
preserve_trailingNfalseIf true, preserve empty trailing values
tagN-Identifier
target_fieldNfieldField to store the resulting array

Details​

When splitting strings, the processor supports both basic string separators and advanced regular expression patterns. The result is stored as an array either in the original field or in a specified target field.

note

Regular expressions are cached for better performance when reused.

warning

The field must contain a string value, otherwise the processor will fail unless ignore_failure is set to true.

Examples​

Basic​

Split string using comma separator...

{
"data": "one,two,three"
}
- split:
field: data
separator: ","

to create an array of values:

{
"data": ["one", "two", "three"]
}

Trailing Values​

Enabling preserve_trailing...

{
"data": "one,two,three,"
}
- split:
field: data
separator: ","
preserve_trailing: true

keeps empty trailing elements:

{
"data": ["one", "two", "three", ""]
}

Regular Expressions​

Splitting on multiple whitespace characters...

{
"message": "hello world test"
}
- split:
field: message
separator: '\s+'

treats consecutive spaces as one separator:

{
"message": ["hello", "world", "test"]
}

Keep Original​

Storing the result in a new field...

{
"tags": "important,urgent,review"
}
- split:
field: tags
separator: ","
target_field: tag_array

preserves the original:

{
"tags": "important,urgent,review",
"tag_array": ["important", "urgent", "review"]
}