Stemmer override token filter
출처: 문서
본문
Stemmer override 토큰 필터
stemmer_override 토큰 필터를 사용하면 Porter나 Snowball 같은 기본 스테머의 동작을 재정의하는 커스텀 스테밍 규칙을 정의할 수 있어요. 표준 스테밍 알고리즘이 올바르게 처리하지 못할 수 있는 특정 단어에 원하는 스테밍 동작을 적용하고 싶을 때 유용해요.
파라미터
stemmer_override 토큰 필터는 다음 파라미터 중 정확히 하나를 사용해 설정해야 해요.
| 파라미터 | 데이터 타입 | 설명 |
|---|---|---|
rules |
String | 재정의 규칙을 설정에 직접 정의해요. |
rules_path |
String | 커스텀 규칙(매핑)이 담긴 파일의 경로를 지정해요. 경로는 절대 경로이거나 config 디렉터리를 기준으로 한 상대 경로일 수 있어요. |
예제
다음 예제 요청은 my-index라는 새 인덱스를 생성하고 stemmer_override 필터가 설정된 애널라이저를 구성해요:
PUT /my-index
{
"settings": {
"analysis": {
"filter": {
"my_stemmer_override_filter": {
"type": "stemmer_override",
"rules": [
"running, runner => run",
"bought => buy",
"best => good"
]
}
},
"analyzer": {
"my_custom_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"my_stemmer_override_filter"
]
}
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
애널라이저를 사용해 생성된 토큰을 확인하려면 다음 요청을 사용해 보세요:
GET /my-index/_analyze
{
"analyzer": "my_custom_analyzer",
"text": "I am a runner and bought the best shoes"
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{
"token": "i",
"start_offset": 0,
"end_offset": 1,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "am",
"start_offset": 2,
"end_offset": 4,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "a",
"start_offset": 5,
"end_offset": 6,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "run",
"start_offset": 7,
"end_offset": 13,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "and",
"start_offset": 14,
"end_offset": 17,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "buy",
"start_offset": 18,
"end_offset": 24,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "the",
"start_offset": 25,
"end_offset": 28,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "good",
"start_offset": 29,
"end_offset": 33,
"type": "<ALPHANUM>",
"position": 7
},
{
"token": "shoes",
"start_offset": 34,
"end_offset": 39,
"type": "<ALPHANUM>",
"position": 8
}
]
}