mirror of
https://github.com/iSharkFly-Docs/opensearch-docs-cn
synced 2025-03-09 14:38:01 +00:00
* Fix APIs File Signed-off-by: samipak458 <samipak458@gmail.com> * Update API files according to API template Signed-off-by: samipak458 <samipak458@gmail.com> * Update exec-stored-script.md Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> * Update cat-aliases.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * Update cat-allocation.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * Update cat-cluster_manager.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * Update cat-count.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * Update cat-field-data.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * Update cat-health.md Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> * updated * updated * updated --------- Signed-off-by: samipak458 <samipak458@gmail.com> Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com> Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com>
132 lines
2.8 KiB
Markdown
132 lines
2.8 KiB
Markdown
---
|
|
layout: default
|
|
title: Remove
|
|
parent: Ingest processors
|
|
nav_order: 230
|
|
redirect_from:
|
|
- /api-reference/ingest-apis/processors/remove/
|
|
---
|
|
|
|
# Remove
|
|
**Introduced 1.0**
|
|
{: .label .label-purple }
|
|
|
|
The `remove` processor is used to remove a field from a document.
|
|
|
|
## Example
|
|
The following is the syntax for the `remove` processor:
|
|
|
|
```json
|
|
{
|
|
"remove": {
|
|
"field": "field_name"
|
|
}
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
#### Configuration parameters
|
|
|
|
The following table lists the required and optional parameters for the `remove` processor.
|
|
|
|
| Name | Required | Description |
|
|
|---|---|---|
|
|
`field` | Required | The name of the field to which the data should be appended. Supports template snippets. |
|
|
`description` | Optional | A brief description of the processor. |
|
|
`if` | Optional | A condition for running this processor. |
|
|
`ignore_failure` | Optional | If set to `true`, 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 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 `remove_ip`, that removes the `ip_address` field from a document:
|
|
|
|
```json
|
|
PUT /_ingest/pipeline/remove_ip
|
|
{
|
|
"description": "Pipeline that excludes the ip_address field.",
|
|
"processors": [
|
|
{
|
|
"remove": {
|
|
"field": "ip_address"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
{% 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/remove_ip/_simulate
|
|
{
|
|
"docs": [
|
|
{
|
|
"_index": "testindex1",
|
|
"_id": "1",
|
|
"_source":{
|
|
"ip_address": "203.0.113.1",
|
|
"name": "John Doe"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
#### Response
|
|
|
|
The following example response confirms that the pipeline is working as expected:
|
|
|
|
```json
|
|
{
|
|
"docs": [
|
|
{
|
|
"doc": {
|
|
"_index": "testindex1",
|
|
"_id": "1",
|
|
"_source": {
|
|
"name": "John Doe"
|
|
},
|
|
"_ingest": {
|
|
"timestamp": "2023-08-24T18:02:13.218986756Z"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**Step 3: Ingest a document.**
|
|
|
|
The following query ingests a document into an index named `testindex1`:
|
|
|
|
```json
|
|
PPUT testindex1/_doc/1?pipeline=remove_ip
|
|
{
|
|
"ip_address": "203.0.113.1",
|
|
"name": "John Doe"
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
**Step 4 (Optional): Retrieve the document.**
|
|
|
|
To retrieve the document, run the following query:
|
|
|
|
```json
|
|
GET testindex1/_doc/1
|
|
```
|
|
{% include copy-curl.html %}
|