印尼语分析器
内置的 indonesian
分析器可以使用以下命令应用于文本字段
PUT /indonesian-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "indonesian"
}
}
}
}
词干排除
您可以使用以下命令将 stem_exclusion
与此语言分析器一起使用
PUT index_with_stem_exclusion_indonesian_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_indonesian_analyzer": {
"type": "indonesian",
"stem_exclusion": ["otoritas", "persetujuan"]
}
}
}
}
}
印尼语分析器内部结构
indonesian
分析器是使用以下组件构建的
-
分词器:
standard
-
词元过滤器
- lowercase
- 停用词 (印尼语)
- keyword
- 词干提取器 (印尼语)
自定义印尼语分析器
您可以使用以下命令创建自定义印尼语分析器
PUT /hungarian-index
{
"settings": {
"analysis": {
"filter": {
"hungarian_stop": {
"type": "stop",
"stopwords": "_hungarian_"
},
"hungarian_stemmer": {
"type": "stemmer",
"language": "hungarian"
},
"hungarian_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"hungarian_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"hungarian_stop",
"hungarian_keywords",
"hungarian_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "hungarian_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /indonesian-index/_analyze
{
"field": "content",
"text": "Mahasiswa belajar di universitas Indonesia. Nomor mereka adalah 123456."
}
响应包含生成的词元
{
"tokens": [
{
"token": "mahasiswa",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ajar",
"start_offset": 10,
"end_offset": 17,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "universitas",
"start_offset": 21,
"end_offset": 32,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "indonesia",
"start_offset": 33,
"end_offset": 42,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "nomor",
"start_offset": 44,
"end_offset": 49,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "123456",
"start_offset": 64,
"end_offset": 70,
"type": "<NUM>",
"position": 8
}
]
}