俄语分析器
内置的 russian
分析器可以使用以下命令应用于文本字段
PUT /russian-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "russian"
}
}
}
}
词干排除
您可以使用以下命令将 stem_exclusion
与此语言分析器一起使用
PUT index_with_stem_exclusion_russian_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_russian_analyzer": {
"type": "russian",
"stem_exclusion": ["авторитет", "одобрение"]
}
}
}
}
}
俄语分析器内部结构
内置的 russian
分析器由以下组件构建
-
分词器:
standard
-
词元过滤器
- 小写
- 停用词 (俄语)
- 关键词
- 词干提取器 (俄语)
自定义俄语分析器
您可以使用以下命令创建自定义俄语分析器
PUT /russian-index
{
"settings": {
"analysis": {
"filter": {
"russian_stop": {
"type": "stop",
"stopwords": "_russian_"
},
"russian_stemmer": {
"type": "stemmer",
"language": "russian"
},
"russian_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"russian_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"russian_stop",
"russian_keywords",
"russian_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "russian_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /russian-index/_analyze
{
"field": "content",
"text": "Студенты учатся в университетах России. Их номера 123456."
}
响应包含生成的词元
{
"tokens": [
{
"token": "студент",
"start_offset": 0,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "учат",
"start_offset": 9,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "университет",
"start_offset": 18,
"end_offset": 31,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "росс",
"start_offset": 32,
"end_offset": 38,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "номер",
"start_offset": 43,
"end_offset": 49,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "123456",
"start_offset": 50,
"end_offset": 56,
"type": "<NUM>",
"position": 7
}
]
}