Swedish analyzer
출처: 문서
본문
스웨덴어 분석기
내장된 swedish 분석기는 다음 명령을 사용해 텍스트 필드에 적용할 수 있어요:
PUT /swedish-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "swedish"
}
}
}
}
{% include copy-curl.html %}
어간 제외
다음 명령을 사용하면 이 언어 분석기에서 stem_exclusion을 사용할 수 있어요:
PUT index_with_stem_exclusion_swedish_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_swedish_analyzer": {
"type": "swedish",
"stem_exclusion": ["myndighet", "godkännande"]
}
}
}
}
}
{% include copy-curl.html %}
스웨덴어 분석기 내부 구조
swedish 분석기는 다음 구성 요소로 만들어져 있어요:
-
토크나이저:
standard -
토큰 필터:
- lowercase
- stop (Swedish)
- keyword
- stemmer (Swedish)
커스텀 스웨덴어 분석기
다음 명령을 사용해 커스텀 스웨덴어 분석기를 만들 수 있어요:
PUT /swedish-index
{
"settings": {
"analysis": {
"filter": {
"swedish_stop": {
"type": "stop",
"stopwords": "_swedish_"
},
"swedish_stemmer": {
"type": "stemmer",
"language": "swedish"
},
"swedish_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"swedish_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"swedish_stop",
"swedish_keywords",
"swedish_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "swedish_analyzer"
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
다음 요청을 사용해 분석기가 생성한 토큰을 확인해 보세요:
POST /swedish-index/_analyze
{
"field": "content",
"text": "Studenter studerar vid svenska universitet. Deras nummer är 123456."
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{
"token": "student",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "studer",
"start_offset": 10,
"end_offset": 18,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "svensk",
"start_offset": 23,
"end_offset": 30,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "universitet",
"start_offset": 31,
"end_offset": 42,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "numm",
"start_offset": 50,
"end_offset": 56,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "123456",
"start_offset": 60,
"end_offset": 66,
"type": "<NUM>",
"position": 8
}
]
}