Rename processor
출처: 문서
본문
Rename processor
rename 프로세서는 기존 필드의 이름을 바꾸는 데 사용되며, 필드를 한 객체에서 다른 객체나 루트 수준으로 이동하는 데도 사용할 수 있어요.
Syntax
다음은 rename 프로세서의 구문이에요:
{
"rename": {
"field": "field_name",
"target_field" : "target_field_name"
}
}
{% include copy.html %}
Configuration parameters
다음 표는 rename 프로세서의 필수 및 선택적 매개변수를 보여줘요.
| Parameter | Required/Optional | Description |
|---|---|---|
field |
Required | 제거할 데이터가 포함된 필드 이름이에요. template snippets을 지원해요. |
target_field |
Required | 필드의 새 이름이에요. template snippets을 지원해요. |
ignore_missing |
Optional | 프로세서가 지정된 field를 포함하지 않은 문서를 무시할지 여부를 지정해요. true로 설정하면 field가 존재하지 않을 때 프로세서가 문서를 수정하지 않아요. 기본값은 false예요. |
override_target |
Optional | 문서에 target_field가 이미 있을 때 어떻게 처리할지 결정해요. true로 설정하면 프로세서가 기존 target_field 값을 새 값으로 덮어써요. false로 설정하면 기존 값이 유지되고 덮어쓰지 않아요. 기본값은 false예요. |
description |
Optional | 프로세서에 대한 간단한 설명이에요. |
if |
Optional | 프로세서 실행 조건이에요. |
ignore_failure |
Optional | 프로세서가 오류가 발생해도 계속 실행할지 여부를 지정해요. true로 설정하면 실패를 무시해요. 기본값은 false예요. |
on_failure |
Optional | 프로세서가 실패할 경우 실행할 프로세서 목록이에요. |
tag |
Optional | 프로세서의 식별 태그예요. 동일한 유형의 프로세서를 구분하는 데 유용해요. |
Using the processor
파이프라인에서 프로세서를 사용하려면 다음 단계를 따라요.
Step 1: Create a pipeline
다음 쿼리는 객체 내 필드를 루트 수준으로 이동하는 rename_field라는 파이프라인을 만들어요:
PUT /_ingest/pipeline/rename_field
{
"description": "Pipeline that moves a field to the root level.",
"processors": [
{
"rename": {
"field": "message.content",
"target_field": "content"
}
}
]
}
{% include copy-curl.html %}
Step 2 (Optional): Test the pipeline
문서를 수집하기 전에 파이프라인을 테스트하는 것이 좋아요. {: .tip}
파이프라인을 테스트하려면 다음 쿼리를 실행해요:
POST _ingest/pipeline/rename_field/_simulate
{
"docs": [
{
"_index": "testindex1",
"_id": "1",
"_source":{
"message": {
"type": "nginx",
"content": "192.168.1.10 - - [03/Nov/2023:15:20:45 +0000] \"POST /login HTTP/1.1\" 200 3456"
}
}
}
]
}
{% include copy-curl.html %}
Response
다음 예시 응답은 파이프라인이 예상대로 작동하고 있음을 확인해줘요:
{
"docs": [
{
"doc": {
"_index": "testindex1",
"_id": "1",
"_source": {
"message": {
"type": "nginx",
},
"content": """192.168.1.10 - - [03/Nov/2023:15:20:45 +0000] "POST /login HTTP/1.1" 200 3456"""
},
"_ingest": {
"timestamp": "2024-04-15T07:54:16.010447Z"
}
}
}
]
}
Step 3: Ingest a document
다음 쿼리는 testindex1이라는 인덱스에 문서를 수집해요:
PUT testindex1/_doc/1?pipeline=rename_field
{
"message": {
"type": "nginx",
"content": "192.168.1.10 - - [03/Nov/2023:15:20:45 +0000] \"POST /login HTTP/1.1\" 200 3456"
}
}
{% include copy-curl.html %}
Step 4 (Optional): Retrieve the document
문서를 검색하려면 다음 쿼리를 실행해요:
GET testindex1/_doc/1
{% include copy-curl.html %}