URL decode processor
출처: 문서
본문
URL 디코드 프로세서
urldecode 프로세서는 로그 데이터나 다른 텍스트 필드에서 URL 인코딩된 문자열을 디코딩하는 데 유용해요. 이렇게 하면 데이터를 더 읽기 쉽고 분석하기 쉽게 만들 수 있어요. 특히 특수 문자나 공백이 포함된 URL이나 쿼리 매개변수를 다룰 때 유용하죠.
다음은 urldecode 프로세서의 구문이에요.
{
"urldecode": {
"field": "field_to_decode",
"target_field": "decoded_field"
}
}
{% include copy.html %}
구성 매개변수
다음 표는 urldecode 프로세서의 필수 및 선택적 매개변수를 나열해요.
| Parameter | Required/Optional | Description |
|---|---|---|
field |
필수 | 디코딩할 URL 인코딩된 문자열이 포함된 필드예요. |
target_field |
선택 | 디코딩된 문자열이 저장되는 필드예요. 지정하지 않으면 디코딩된 문자열이 원래 인코딩된 문자열과 동일한 필드에 저장돼요. |
ignore_missing |
선택 | 프로세서가 지정된 field를 포함하지 않은 문서를 무시할지 여부를 지정해요. true로 설정하면 프로세서가 field의 누락 값을 무시하고 target_field를 변경하지 않아요. 기본값은 false예요. |
description |
선택 | 프로세서에 대한 간단한 설명이에요. |
if |
선택 | 프로세서 실행 조건이에요. |
ignore_failure |
선택 | 프로세서가 오류가 발생해도 계속 실행될지 여부를 지정해요. true로 설정하면 실패를 무시해요. 기본값은 false예요. |
on_failure |
선택 | 프로세서가 실패할 경우 실행할 프로세서 목록이에요. |
tag |
선택 | 프로세서의 식별 태그예요. 동일한 유형의 프로세서를 구분하기 위해 디버깅에 유용해요. |
프로세서 사용하기
파이프라인에서 프로세서를 사용하려면 다음 단계를 따르세요.
1단계: 파이프라인 생성하기
다음 쿼리는 urldecode 프로세서를 사용하여 encoded_url 필드의 URL 인코딩된 문자열을 디코딩하고 디코딩된 문자열을 decoded_url 필드에 저장하는 urldecode_pipeline이라는 파이프라인을 생성해요.
PUT _ingest/pipeline/urldecode_pipeline
{
"description": "Decode URL-encoded strings",
"processors": [
{
"urldecode": {
"field": "encoded_url",
"target_field": "decoded_url"
}
}
]
}
{% include copy-curl.html %}
2단계 (선택): 파이프라인 테스트하기
문서를 수집하기 전에 파이프라인을 테스트하는 것이 좋아요. {: .tip}
파이프라인을 테스트하려면 다음 쿼리를 실행하세요.
POST _ingest/pipeline/urldecode_pipeline/_simulate
{
"docs": [
{
"_source": {
"encoded_url": "https://example.com/search?q=hello%20world"
}
}
]
}
{% include copy-curl.html %}
응답
다음 예제 응답은 파이프라인이 예상대로 작동하고 있음을 확인해요.
{
"docs": [
{
"doc": {
"_index": "_index",
"_id": "_id",
"_source": {
"decoded_url": "https://example.com/search?q=hello world",
"encoded_url": "https://example.com/search?q=hello%20world"
},
"_ingest": {
"timestamp": "2024-04-25T23:16:44.886165001Z"
}
}
}
]
}
{% include copy-curl.html %}
3단계: 문서 수집하기
다음 쿼리는 testindex1이라는 인덱스에 문서를 수집해요.
PUT testindex1/_doc/1?pipeline=url_decode_pipeline
{
"encoded_url": "https://example.com/search?q=url%20decode%20test"
}
{% include copy-curl.html %}
응답
앞의 요청은 문서를 testindex1 인덱스에 인덱싱하고 encoded_url 필드를 포함하는 모든 문서를 인덱싱하며, 이 필드는 urldecode_pipeline에 의해 처리되어 decoded_url 필드를 채워요. 다음 응답에서 확인할 수 있어요.
{
"_index": "testindex1",
"_id": "1",
"_version": 67,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 68,
"_primary_term": 47
}
{% include copy-curl.html %}
4단계 (선택): 문서 검색하기
문서를 검색하려면 다음 쿼리를 실행하세요.
GET testindex1/_doc/1
{% include copy-curl.html %}
응답
응답에는 원래 encoded_url 필드와 decoded_url 필드가 포함돼요.
{
"_index": "testindex1",
"_id": "1",
"_version": 67,
"_seq_no": 68,
"_primary_term": 47,
"found": true,
"_source": {
"decoded_url": "https://example.com/search?q=url decode test",
"encoded_url": "https://example.com/search?q=url%20decode%20test"
}
}
{% include copy-curl.html %}