Skip to main content
Version: 1.2.0

Take

Filter Data Extraction

Synopsis

A data extraction processor that takes a specified number of characters from strings or elements from arrays, supporting extraction from the beginning or end of the data with optional reversal of the extracted content.

Schema

- take:
field: <ident>
length: <string>
target_field: <ident>
reverse: <boolean>
mirror: <boolean>
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:

FieldRequiredDefaultDescription
fieldY-Field containing the string or array to process
lengthNallNumber of characters or elements to take
target_fieldNfieldField to store the extracted content
reverseNfalseTake from end instead of beginning
mirrorNfalseReverse the order of taken elements
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue if extraction fails
ignore_missingNfalseContinue if source field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The processor supports extraction from multiple data types including strings, string arrays, and generic interface arrays. When no length is specified, the entire content is returned.

note

The length parameter accepts string values for template compatibility and dynamic length calculation.

String processing extracts the specified number of characters, while array processing extracts elements. The reverse option allows extraction from the end of the data, useful for getting file extensions or recent log entries.

The mirror option reverses the order of extracted content after taking, providing additional flexibility for data manipulation scenarios.

warning

Ensure the length parameter contains valid numeric values to avoid processing errors.

Examples

String Character Extraction

Taking first characters from a string...

{
"filename": "document.pdf",
"message": "Hello World"
}
- take:
field: message
length: "5"
target_field: greeting

extracts the beginning:

{
"filename": "document.pdf",
"message": "Hello World",
"greeting": "Hello"
}

File Extension Extraction

Taking last characters for extension...

{
"filename": "report.xlsx"
}
- take:
field: filename
length: "4"
reverse: true
target_field: extension

extracts the file extension:

{
"filename": "report.xlsx",
"extension": "xlsx"
}

Array Element Extraction

Taking elements from an array...

{
"tags": ["urgent", "security", "network", "firewall", "alert"]
}
- take:
field: tags
length: "3"
target_field: primary_tags

extracts first three elements:

{
"tags": ["urgent", "security", "network", "firewall", "alert"],
"primary_tags": ["urgent", "security", "network"]
}

Recent Log Entries

Getting recent entries from end of array...

{
"log_entries": [
"2024-01-15 08:00:00 - System start",
"2024-01-15 09:15:00 - User login",
"2024-01-15 10:30:00 - File access",
"2024-01-15 11:45:00 - Network error",
"2024-01-15 12:00:00 - Error resolved"
]
}
- take:
field: log_entries
length: "2"
reverse: true
target_field: recent_logs

extracts the most recent entries:

{
"log_entries": [
"2024-01-15 08:00:00 - System start",
"2024-01-15 09:15:00 - User login",
"2024-01-15 10:30:00 - File access",
"2024-01-15 11:45:00 - Network error",
"2024-01-15 12:00:00 - Error resolved"
],
"recent_logs": [
"2024-01-15 11:45:00 - Network error",
"2024-01-15 12:00:00 - Error resolved"
]
}

Mirrored Text Extraction

Taking and reversing characters...

{
"code": "ABC123XYZ"
}
- take:
field: code
length: "6"
mirror: true
target_field: reversed_prefix

extracts and reverses the prefix:

{
"code": "ABC123XYZ",
"reversed_prefix": "321CBA"
}

In-Place Processing

Truncating field in place...

{
"description": "This is a very long description that needs to be truncated for display purposes"
}
- take:
field: description
length: "50"

truncates the original field:

{
"description": "This is a very long description that needs to be "
}