'특수문자'에 해당되는 글 1건

  1. 2018.10.04 [Elasticsearch] _analyze 예제 - 특수문자 제거

[Elasticsearch] _analyze 예제 - 특수문자 제거

Elastic/Elasticsearch 2018. 10. 4. 08:02

색인 시점에 text 에 포함된 특수 문자를 제거 하기 위한 예시 입니다.


[실행]

curl -X POST \

  http://localhost:9200/_analyze \

  -H 'cache-control: no-cache' \

  -H 'content-type: application/json' \

  -d '{

  "tokenizer": "arirang_tokenizer",

  "filter":[

              "lowercase",

              "trim",

              "arirang_filter"

            ],

  "char_filter" : [{

          "type": "pattern_replace",

          "pattern": "\\p{Punct}|\\d",

          "replacement": " "

        }],

  "text": "애플(&<>,./^!@+=;:%)파이"

}'



[결과]

{

    "tokens": [

        {

            "token": "애플",

            "start_offset": 0,

            "end_offset": 2,

            "type": "korean",

            "position": 0

        },

        {

            "token": "파이",

            "start_offset": 18,

            "end_offset": 20,

            "type": "korean",

            "position": 1

        }

    ]

}


: