Remove by pattern processor
출처: 문서
본문
패턴별 제거 프로세서
remove_by_pattern 프로세서는 지정된 와일드카드 패턴을 사용하여 문서에서 루트 수준 필드를 제거해요.
구문
remove_by_pattern 프로세서의 구문은 다음과 같아요:
{
"remove_by_pattern": {
"field_pattern": "field_name_prefix*"
}
}
{% include copy.html %}
구성 파라미터
다음 표는 remove_by_pattern 프로세서의 필수 및 선택적 파라미터를 보여줘요.
| Parameter | Required/Optional | Description |
|---|---|---|
field_pattern |
Optional | 지정된 패턴과 일치하는 필드를 제거해요. _index, _version, _version_type, _id와 같은 모든 메타데이터 필드는 패턴과 일치하더라도 무시돼요. 이 옵션은 문서의 루트 수준 필드만 지원해요. |
exclude_field_pattern |
Optional | 지정된 패턴과 일치하지 않는 필드를 제거해요. _index, _version, _version_type, _id와 같은 모든 메타데이터 필드는 패턴과 일치하지 않더라도 무시돼요. 이 옵션은 문서의 루트 수준 필드만 지원해요. field_pattern과 exclude_field_pattern 옵션은 상호 배타적이에요. |
description |
Optional | 프로세서에 대한 간단한 설명이에요. |
if |
Optional | 프로세서 실행 조건이에요. |
ignore_failure |
Optional | 프로세서가 오류를 만나도 계속 실행할지 여부를 지정해요. true로 설정하면 실패를 무시해요. 기본값은 false예요. |
on_failure |
Optional | 프로세서가 실패할 경우 실행할 프로세서 목록이에요. |
tag |
Optional | 프로세서의 식별 태그예요. 동일한 유형의 프로세서를 구분하는 디버깅에 유용해요. |
프로세서 사용하기
파이프라인에서 프로세서를 사용하려면 다음 단계를 따라요.
1단계: 파이프라인 생성
다음 쿼리는 foo* 패턴과 일치하는 필드를 제거하는 remove_fields_by_pattern이라는 파이프라인을 생성해요.
PUT /_ingest/pipeline/remove_fields_by_pattern
{
"description": "Pipeline that removes the fields by patterns.",
"processors": [
{
"remove_by_pattern": {
"field_pattern": "foo*"
}
}
]
}
{% include copy-curl.html %}
2단계(선택 사항): 파이프라인 테스트
문서를 수집하기 전에 파이프라인을 테스트하는 것이 좋아요. {: .tip}
파이프라인을 테스트하려면 다음 쿼리를 실행해요:
POST _ingest/pipeline/remove_fields_by_pattern/_simulate
{
"docs": [
{
"_index": "testindex1",
"_id": "1",
"_source":{
"foo1": "foo1",
"foo2": "foo2",
"bar": "bar"
}
}
]
}
{% include copy-curl.html %}
응답
다음 예시 응답은 파이프라인이 예상대로 작동하고 있음을 확인해줘요:
{
"docs": [
{
"doc": {
"_index": "testindex1",
"_id": "1",
"_source": {
"bar": "bar"
},
"_ingest": {
"timestamp": "2023-08-24T18:02:13.218986756Z"
}
}
}
]
}
3단계: 문서 수집
다음 쿼리는 testindex1이라는 인덱스에 문서를 수집해요:
PUT testindex1/_doc/1?pipeline=remove_fields_by_pattern
{
"foo1": "foo1",
"foo2": "foo2",
"bar": "bar"
}
{% include copy-curl.html %}
4단계(선택 사항): 문서 검색
문서를 검색하려면 다음 쿼리를 실행해요:
GET testindex1/_doc/1
{% include copy-curl.html %}