Danish analyzer
The built-in danish
analyzer can be applied to a text field using the following command:
PUT /danish-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "danish"
}
}
}
}
copy
Stem exclusion
You can use stem_exclusion
with this language analyzer using the following command:
PUT index_with_stem_exclusion_danish_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_danish_analyzer": {
"type": "danish",
"stem_exclusion": ["autoritet", "godkendelse"]
}
}
}
}
}
copy
Danish analyzer internals
The danish
analyzer is built using the following components:
Tokenizer:
standard
Token filters:
- lowercase
- stop (Danish)
- keyword
- stemmer (Danish)
Custom Danish analyzer
You can create a custom Danish analyzer using the following command:
PUT /danish-index
{
"settings": {
"analysis": {
"filter": {
"danish_stop": {
"type": "stop",
"stopwords": "_danish_"
},
"danish_stemmer": {
"type": "stemmer",
"language": "danish"
},
"danish_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"analyzer": {
"danish_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"danish_stop",
"danish_keywords",
"danish_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "danish_analyzer"
}
}
}
}
copy
Generated tokens
Use the following request to examine the tokens generated using the analyzer:
POST /danish-index/_analyze
{
"field": "content",
"text": "Studerende studerer på de danske universiteter. Deres numre er 123456."
}
copy
The response contains the generated tokens:
{
"tokens": [
{
"token": "stud",
"start_offset": 0,
"end_offset": 10,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "stud",
"start_offset": 11,
"end_offset": 19,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "dansk",
"start_offset": 26,
"end_offset": 32,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "universitet",
"start_offset": 33,
"end_offset": 46,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "numr",
"start_offset": 54,
"end_offset": 59,
"type": "<ALPHANUM>",
"position": 7
},
{
"token": "123456",
"start_offset": 63,
"end_offset": 69,
"type": "<NUM>",
"position": 9
}
]
}
当前内容版权归 OpenSearch 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 OpenSearch .