Normalizers
출처: 문서
본문
노멀라이저
_노멀라이저_는 애널라이저와 비슷하게 동작하지만 단일 토큰만 출력해요. 토크나이저는 포함하지 않고, 특정 타입의 캐릭터 필터와 토큰 필터만 포함할 수 있어요. 이 필터들은 문자 교체나 패턴 치환 같은 문자 수준 연산만 수행할 수 있고, 토큰 전체를 대상으로는 동작할 수 없어요. 즉, 토큰을 동의어로 바꾸거나 어간 추출을 적용하는 기능은 지원되지 않아요.
노멀라이저는 키워드 검색(즉, 텀 기반 쿼리)에서 유용해요. 임의의 입력에 토큰 필터와 캐릭터 필터를 실행할 수 있기 때문이에요. 예를 들어, 들어온 쿼리 Naïve를 인덱스 텀 naive와 매칭하는 게 가능해져요.
다음 예제를 살펴봐요.
커스텀 노멀라이저로 새 인덱스를 생성해요:
PUT /sample-index
{
"settings": {
"analysis": {
"normalizer": {
"normalized_keyword": {
"type": "custom",
"char_filter": [],
"filter": [ "asciifolding", "lowercase" ]
}
}
}
},
"mappings": {
"properties": {
"approach": {
"type": "keyword",
"normalizer": "normalized_keyword"
}
}
}
}
{% include copy-curl.html %}
문서를 인덱싱해요:
POST /sample-index/_doc/
{
"approach": "naive"
}
{% include copy-curl.html %}
다음 쿼리는 해당 문서와 매칭돼요. 예상된 결과예요:
GET /sample-index/_search
{
"query": {
"term": {
"approach": "naive"
}
}
}
{% include copy-curl.html %}
하지만 이 쿼리 역시 문서와 매칭돼요:
GET /sample-index/_search
{
"query": {
"term": {
"approach": "Naïve"
}
}
}
{% include copy-curl.html %}
그 이유를 이해하려면 노멀라이저가 실제로 어떤 효과를 내는지 살펴봐요:
GET /sample-index/_analyze
{
"normalizer" : "normalized_keyword",
"text" : "Naïve"
}
내부적으로 노멀라이저는 NormalizingTokenFilterFactory 또는 NormalizingCharFilterFactory의 인스턴스인 필터만 받아들여요. 다음은 OpenSearch 코어 저장소에 포함된 모듈과 플러그인에서 찾을 수 있는 호환 가능한 필터 목록이에요.
common-analysis 모듈
이 모듈은 설치가 필요 없고 기본적으로 제공돼요.
캐릭터 필터: pattern_replace, mapping
토큰 필터: arabic_normalization, asciifolding, bengali_normalization, cjk_width, decimal_digit, elision, german_normalization, hindi_normalization, indic_normalization, lowercase, persian_normalization, scandinavian_folding, scandinavian_normalization, serbian_normalization, sorani_normalization, trim, truncate, uppercase
analysis-icu 플러그인
캐릭터 필터: icu_normalizer
토큰 필터: icu_normalizer, icu_folding, icu_transform
analysis-kuromoji 플러그인
캐릭터 필터: kuromoji_iteration_mark
이 필터 목록에는 OpenSearch 코어 저장소에 포함된 추가 플러그인에서 찾을 수 있는 분석 컴포넌트만 담겨 있어요. {: .note}