Rename field processor
출처: 문서
본문
필드 이름 바꾸기 프로세서
2.8에서 도입됨 {: .label .label-purple }
rename_field 검색 응답 프로세서는 검색 응답을 가로채서 지정된 필드의 이름을 바꿉니다. 이는 인덱스와 애플리케이션이 동일한 필드에 대해 다른 이름을 사용할 때 유용합니다. 예를 들어, 인덱스에서 필드 이름을 변경한 경우 rename_field 프로세서가 응답을 애플리케이션으로 보내기 전에 새 이름을 이전 이름으로 변경할 수 있습니다.
요청 본문 필드
다음 표는 사용 가능한 모든 요청 필드를 나열합니다.
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
field |
String | 이름을 바꿀 필드입니다. 필수. |
target_field |
String | 새 필드 이름입니다. 필수. |
tag |
String | 프로세서의 식별자입니다. |
description |
String | 프로세서에 대한 설명입니다. |
ignore_failure |
Boolean | true인 경우 OpenSearch는 이 프로세서의 모든 실패를 무시하고 검색 파이프라인에서 나머지 프로세서를 계속 실행합니다. 선택 사항. 기본값은 false입니다. |
예제
다음 예제는 rename_field 프로세서를 사용하는 검색 파이프라인을 보여줍니다.
설정
my_index라는 인덱스를 생성하고 message 필드가 있는 문서를 인덱싱합니다:
POST /my_index/_doc/1
{
"message": "This is a public message",
"visibility":"public"
}
{% include copy-curl.html %}
검색 파이프라인 생성
다음 요청은 message 필드를 notification으로 이름을 바꾸는 rename_field 응답 프로세서가 있는 검색 파이프라인을 생성합니다:
PUT /_search/pipeline/my_pipeline
{
"response_processors": [
{
"rename_field": {
"field": "message",
"target_field": "notification"
}
}
]
}
{% include copy-curl.html %}
검색 파이프라인 사용
검색 파이프라인 없이 my_index에서 문서를 검색합니다:
GET /my_index/_search
{% include copy-curl.html %}
응답에는 message 필드가 포함됩니다:
응답
{: .text-delta} ```json { "took" : 1, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "my_index", "_id" : "1", "_score" : 1.0, "_source" : { "message" : "This is a public message", "visibility" : "public" } } ] } } ```파이프라인으로 검색하려면 search_pipeline 쿼리 매개변수에 파이프라인 이름을 지정합니다:
GET /my_index/_search?search_pipeline=my_pipeline
{% include copy-curl.html %}
message 필드가 notification으로 이름이 바뀌었습니다:
응답
{: .text-delta} ```json { "took" : 2, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1, "relation" : "eq" }, "max_score" : 0.0, "hits" : [ { "_index" : "my_index", "_id" : "1", "_score" : 0.0, "_source" : { "visibility" : "public", "notification" : "This is a public message" } } ] } } ```fields 옵션을 사용하여 문서에서 특정 필드를 검색할 수도 있습니다:
POST /my_index/_search?pretty&search_pipeline=my_pipeline
{
"fields":["visibility", "message"]
}
{% include copy-curl.html %}
응답에서 message 필드가 notification으로 이름이 바뀌었습니다:
응답
{: .text-delta} ```json { "took" : 4, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1, "relation" : "eq" }, "max_score" : 0.0, "hits" : [ { "_index" : "my_index", "_id" : "1", "_score" : 0.0, "_source" : { "visibility" : "public", "notification" : "This is a public message" }, "fields" : { "visibility" : [ "public" ], "notification" : [ "This is a public message" ] } } ] } }</details>
## 더 알아보기 (Learn more)
- 원문 전체: https://docs.opensearch.org/latest/search-plugins/search-pipelines/rename-field-processor/