捷克语分析器
内置的 czech
分析器可以使用以下命令应用于文本字段
PUT /czech-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "czech"
}
}
}
}
词干排除
您可以使用以下命令将 stem_exclusion
与此语言分析器一起使用
PUT index_with_stem_exclusion_czech_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_czech_analyzer": {
"type": "czech",
"stem_exclusion": ["autorita", "schválení"]
}
}
}
}
}
捷克语分析器内部
“czech
”分析器是使用以下组件构建的
-
分词器:
standard
-
词元过滤器
- lowercase
- stop (捷克语)
- keyword
- stemmer (捷克语)
自定义捷克语分析器
您可以使用以下命令创建自定义捷克语分析器
PUT /czech-index
{
"settings": {
"analysis": {
"filter": {
"czech_stop": {
"type": "stop",
"stopwords": "_czech_"
},
"czech_stemmer": {
"type": "stemmer",
"language": "czech"
},
"czech_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"czech_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"czech_stop",
"czech_keywords",
"czech_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "czech_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /czech-index/_analyze
{
"field": "content",
"text": "Studenti studují na českých univerzitách. Jejich čísla jsou 123456."
}
响应包含生成的词元
{
"tokens": [
{
"token": "student",
"start_offset": 0,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "studuj",
"start_offset": 9,
"end_offset": 16,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "česk",
"start_offset": 20,
"end_offset": 27,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "univerzit",
"start_offset": 28,
"end_offset": 40,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "čísl",
"start_offset": 49,
"end_offset": 54,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "123456",
"start_offset": 60,
"end_offset": 66,
"type": "<NUM>",
"position": 8
}
]
}