Thai analyzer
출처: 문서
본문
태국어 분석기
내장된 thai 분석기는 다음 명령어를 사용해 텍스트 필드에 적용할 수 있어요:
PUT /thai-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "thai"
}
}
}
}
{% include copy-curl.html %}
어간 제외
다음 명령어를 사용하면 이 언어 분석기에 stem_exclusion을 사용할 수 있어요:
PUT index_with_stem_exclusion_thai_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_thai_analyzer": {
"type": "thai",
"stem_exclusion": ["อำนาจ", "การอนุมัติ"]
}
}
}
}
}
{% include copy-curl.html %}
태국어 분석기 내부 구조
thai 분석기는 다음 구성 요소로 이루어져 있어요:
-
토크나이저:
thai -
토큰 필터:
- lowercase
- decimal_digit
- stop (Thai)
- keyword
커스텀 태국어 분석기
다음 명령어를 사용해 커스텀 태국어 분석기를 만들 수 있어요:
PUT /thai-index
{
"settings": {
"analysis": {
"filter": {
"thai_stop": {
"type": "stop",
"stopwords": "_thai_"
},
"thai_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"thai_analyzer": {
"tokenizer": "thai",
"filter": [
"lowercase",
"decimal_digit",
"thai_stop",
"thai_keywords"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "thai_analyzer"
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
다음 요청을 사용해 분석기가 생성한 토큰을 확인해 보세요:
POST /thai-index/_analyze
{
"field": "content",
"text": "นักเรียนกำลังศึกษาอยู่ที่มหาวิทยาลัยไทย หมายเลข 123456."
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{"token": "นักเรียน","start_offset": 0,"end_offset": 8,"type": "word","position": 0},
{"token": "กำลัง","start_offset": 8,"end_offset": 13,"type": "word","position": 1},
{"token": "ศึกษา","start_offset": 13,"end_offset": 18,"type": "word","position": 2},
{"token": "มหาวิทยาลัย","start_offset": 25,"end_offset": 36,"type": "word","position": 5},
{"token": "ไทย","start_offset": 36,"end_offset": 39,"type": "word","position": 6},
{"token": "หมายเลข","start_offset": 40,"end_offset": 47,"type": "word","position": 7},
{"token": "123456","start_offset": 48,"end_offset": 54,"type": "word","position": 8}
]
}