generated from amazon-archives/__template_Apache-2.0
-
Couldn't load subscription status.
- Fork 621
[DOC] Add split processor documentation #5991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
80f75a0
Add split processor documentation
vagimeli a6253ea
Merge branch 'main' into split-processor
vagimeli be12c45
Writing and editing
vagimeli 62aab85
Merge branch 'main' into split-processor
vagimeli 7a5a047
Update _ingest-pipelines/processors/split.md
vagimeli f67c488
Update _ingest-pipelines/processors/split.md
vagimeli 2d64635
Update _ingest-pipelines/processors/split.md
vagimeli 1613bd0
Update split.md
vagimeli bac35e9
Merge branch 'main' into split-processor
vagimeli 9ede1cc
Update _ingest-pipelines/processors/split.md
vagimeli 0c8ab5f
Update _ingest-pipelines/processors/split.md
vagimeli b5eb38b
Update split.md
vagimeli d3d11a7
Update _ingest-pipelines/processors/split.md
vagimeli 81d8b47
Merge branch 'main' into split-processor
vagimeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| --- | ||
| layout: default | ||
| title: Split | ||
| parent: Ingest processors | ||
| nav_order: 270 | ||
| --- | ||
|
|
||
| # Split processor | ||
|
|
||
| The `split` processor is used to split a string field into an array of substrings based on a specified delimiter. | ||
|
|
||
| The following is the syntax for the `split` processor: | ||
|
|
||
| ```json | ||
| { | ||
| "split": { | ||
| "field": "field_to_split", | ||
| "separator": "<delimiter>", | ||
| "target_field": "split_field" | ||
| } | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ## Configuration parameters | ||
|
|
||
| The following table lists the required and optional parameters for the `split` processor. | ||
|
|
||
| Parameter | Required/Optional | Description | | ||
| |-----------|-----------|-----------| | ||
| `field` | Required | The field containing the string to be split. | ||
| `separator` | Required | The delimiter used to split the string. This can be a regular expression pattern. | ||
| `preserve_field` | Optional | If set to `true`, preserves empty trailing fields (for example, `''`) in the resulting array. If set to `false`, empty trailing fields are removed from the resulting array. Default is `false`. | ||
| `target_field` | Optional | The field where the array of substrings is stored. If not specified, then the field is updated in-place. | ||
| `ignore_missing` | Optional | Specifies whether the processor should ignore documents that do not contain the specified | ||
| field. If set to `true`, then the processor ignores missing values in the field and leaves the `target_field` unchanged. Default is `false`. | ||
| `description` | Optional | A brief description of the processor. | ||
| `if` | Optional | A condition for running the processor. | ||
| `ignore_failure` | Optional | Specifies whether the processor continues execution even if it encounters an error. If set to `true`, then failures are ignored. Default is `false`. | ||
| `on_failure` | Optional | A list of processors to run if the processor fails. | ||
| `tag` | Optional | An identifier tag for the processor. Useful for debugging in order to distinguish between processors of the same type. | ||
|
|
||
| ## Using the processor | ||
|
|
||
| Follow these steps to use the processor in a pipeline. | ||
|
|
||
| ### Step 1: Create a pipeline | ||
|
|
||
| The following query creates a pipeline named `split_pipeline` that uses the `split` processor to split the `log_message` field on the comma character and store the resulting array in the `log_parts` field: | ||
|
|
||
| ```json | ||
| PUT _ingest/pipeline/split_pipeline | ||
| { | ||
| "description": "Split log messages by comma", | ||
| "processors": [ | ||
| { | ||
| "split": { | ||
| "field": "log_message", | ||
| "separator": ",", | ||
| "target_field": "log_parts" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ### Step 2 (Optional): Test the pipeline | ||
|
|
||
| It is recommended that you test your pipeline before you ingest documents. | ||
| {: .tip} | ||
|
|
||
| To test the pipeline, run the following query: | ||
|
|
||
| ```json | ||
| POST _ingest/pipeline/split_pipeline/_simulate | ||
| { | ||
| "docs": [ | ||
| { | ||
| "_source": { | ||
| "log_message": "error,warning,info" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Response | ||
|
|
||
| The following example response confirms that the pipeline is working as expected: | ||
|
|
||
| ```json | ||
| { | ||
| "docs": [ | ||
| { | ||
| "doc": { | ||
| "_index": "_index", | ||
| "_id": "_id", | ||
| "_source": { | ||
| "log_message": "error,warning,info", | ||
| "log_parts": [ | ||
| "error", | ||
| "warning", | ||
| "info" | ||
| ] | ||
| }, | ||
| "_ingest": { | ||
| "timestamp": "2024-04-26T22:29:23.207849376Z" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ### Step 3: Ingest a document | ||
|
|
||
| The following query ingests a document into an index named `testindex1`: | ||
|
|
||
| ```json | ||
| PUT testindex1/_doc/1?pipeline=split_pipeline | ||
| { | ||
| "log_message": "error,warning,info" | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Response | ||
|
|
||
| The request indexes the document into the index `testindex1` and splits the `log_message` field on the comma delimiter before indexing, as shown in the following response: | ||
|
|
||
| ```json | ||
| { | ||
| "_index": "testindex1", | ||
| "_id": "1", | ||
| "_version": 70, | ||
| "result": "updated", | ||
| "_shards": { | ||
| "total": 2, | ||
| "successful": 1, | ||
| "failed": 0 | ||
| }, | ||
| "_seq_no": 72, | ||
| "_primary_term": 47 | ||
| } | ||
| ``` | ||
|
|
||
| ### Step 4 (Optional): Retrieve the document | ||
|
|
||
| To retrieve the document, run the following query: | ||
|
|
||
| ```json | ||
| GET testindex1/_doc/1 | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Response | ||
|
|
||
| The response shows the `log_message` field as an array of values split on the comma delimiter: | ||
|
|
||
| ```json | ||
| { | ||
| "_index": "testindex1", | ||
| "_id": "1", | ||
| "_version": 70, | ||
| "_seq_no": 72, | ||
| "_primary_term": 47, | ||
| "found": true, | ||
| "_source": { | ||
| "log_message": "error,warning,info", | ||
| "log_parts": [ | ||
| "error", | ||
| "warning", | ||
| "info" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.