Thai analyzer
The built-in thai
analyzer can be applied to a text field using the following command:
PUT /thai-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "thai"
}
}
}
}
copy
Stem exclusion
You can use stem_exclusion
with this language analyzer using the following command:
PUT index_with_stem_exclusion_thai_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_thai_analyzer": {
"type": "thai",
"stem_exclusion": ["อำนาจ", "การอนุมัติ"]
}
}
}
}
}
copy
Thai analyzer internals
The thai
analyzer is built using the following components:
Tokenizer:
thai
Token filters:
- lowercase
- decimal_digit
- stop (Thai)
- keyword
Custom Thai analyzer
You can create a custom Thai analyzer using the following command:
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"
}
}
}
}
copy
Generated tokens
Use the following request to examine the tokens generated using the analyzer:
POST /thai-index/_analyze
{
"field": "content",
"text": "นักเรียนกำลังศึกษาอยู่ที่มหาวิทยาลัยไทย หมายเลข 123456."
}
copy
The response contains the generated tokens:
{
"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}
]
}
当前内容版权归 OpenSearch 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 OpenSearch .