爱尔兰语分析器
内置的 irish
分析器可以使用以下命令应用于文本字段
PUT /irish-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "irish"
}
}
}
}
词干排除
您可以使用以下命令将 stem_exclusion
与此语言分析器一起使用
PUT index_with_stem_exclusion_irish_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_irish_analyzer": {
"type": "irish",
"stem_exclusion": ["údarás", "faomhadh"]
}
}
}
}
}
爱尔兰语分析器内部
irish
分析器使用以下组件构建
-
分词器:
standard
-
词元过滤器
- 连字符 (爱尔兰语)
- 省音 (爱尔兰语)
- 小写 (爱尔兰语)
- 停用词 (爱尔兰语)
- 关键词
- 词干提取器 (爱尔兰语)
自定义爱尔兰语分析器
您可以使用以下命令创建自定义爱尔兰语分析器
PUT /irish-index
{
"settings": {
"analysis": {
"filter": {
"irish_stop": {
"type": "stop",
"stopwords": "_irish_"
},
"irish_elision": {
"type": "elision",
"articles": [ "d", "m", "b" ],
"articles_case": true
},
"irish_hyphenation": {
"type": "stop",
"stopwords": [ "h", "n", "t" ],
"ignore_case": true
},
"irish_lowercase": {
"type": "lowercase",
"language": "irish"
},
"irish_stemmer": {
"type": "stemmer",
"language": "irish"
},
"irish_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"irish_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"irish_hyphenation",
"irish_elision",
"irish_lowercase",
"irish_stop",
"irish_keywords",
"irish_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "irish_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /irish-index/_analyze
{
"field": "content",
"text": "Tá mic léinn ag staidéar in ollscoileanna na hÉireann. Is iad a gcuid uimhreacha ná 123456."
}
响应包含生成的词元
{
"tokens": [
{"token": "tá","start_offset": 0,"end_offset": 2,"type": "<ALPHANUM>","position": 0},
{"token": "mic","start_offset": 3,"end_offset": 6,"type": "<ALPHANUM>","position": 1},
{"token": "léinn","start_offset": 7,"end_offset": 12,"type": "<ALPHANUM>","position": 2},
{"token": "staidéar","start_offset": 16,"end_offset": 24,"type": "<ALPHANUM>","position": 4},
{"token": "ollscoileanna","start_offset": 28,"end_offset": 41,"type": "<ALPHANUM>","position": 6},
{"token": "héireann","start_offset": 45,"end_offset": 53,"type": "<ALPHANUM>","position": 8},
{"token": "cuid","start_offset": 64,"end_offset": 69,"type": "<ALPHANUM>","position": 12},
{"token": "uimhreacha","start_offset": 70,"end_offset": 80,"type": "<ALPHANUM>","position": 13},
{"token": "123456","start_offset": 84,"end_offset": 90,"type": "<NUM>","position": 15}
]
}