荷兰语分析器
内置的 dutch
分析器可以使用以下命令应用于文本字段
PUT /dutch-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "dutch"
}
}
}
}
词干排除
您可以使用以下命令将 stem_exclusion
与此语言分析器一起使用
PUT index_with_stem_exclusion_dutch_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_dutch_analyzer": {
"type": "dutch",
"stem_exclusion": ["autoriteit", "goedkeuring"]
}
}
}
}
}
荷兰语分析器内部结构
该 dutch
分析器由以下组件构建
-
分词器:
standard
-
词元过滤器
- 小写
- 停用词 (荷兰语)
- 关键词
- 词干提取器覆盖
- 词干提取器 (荷兰语)
自定义荷兰语分析器
您可以使用以下命令创建自定义荷兰语分析器
PUT /dutch-index
{
"settings": {
"analysis": {
"filter": {
"dutch_stop": {
"type": "stop",
"stopwords": "_dutch_"
},
"dutch_stemmer": {
"type": "stemmer",
"language": "dutch"
},
"dutch_keywords": {
"type": "keyword_marker",
"keywords": []
},
"dutch_override": {
"type": "stemmer_override",
"rules": [
"fiets=>fiets",
"bromfiets=>bromfiets",
"ei=>eier",
"kind=>kinder"
]
}
},
"analyzer": {
"dutch_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"dutch_stop",
"dutch_keywords",
"dutch_override",
"dutch_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "dutch_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /dutch-index/_analyze
{
"field": "content",
"text": "De studenten studeren in Nederland en bezoeken Amsterdam. Hun nummers zijn 123456."
}
响应包含生成的词元
{
"tokens": [
{"token": "student","start_offset": 3,"end_offset": 12,"type": "<ALPHANUM>","position": 1},
{"token": "studer","start_offset": 13,"end_offset": 21,"type": "<ALPHANUM>","position": 2},
{"token": "nederland","start_offset": 25,"end_offset": 34,"type": "<ALPHANUM>","position": 4},
{"token": "bezoek","start_offset": 38,"end_offset": 46,"type": "<ALPHANUM>","position": 6},
{"token": "amsterdam","start_offset": 47,"end_offset": 56,"type": "<ALPHANUM>","position": 7},
{"token": "nummer","start_offset": 62,"end_offset": 69,"type": "<ALPHANUM>","position": 9},
{"token": "123456","start_offset": 75,"end_offset": 81,"type": "<NUM>","position": 11}
]
}