小写分词器
小写分词器在空白处将文本分解为词项,然后将所有词项转换为小写。功能上,这与使用 letter
分词器配置 lowercase
词元过滤器相同。然而,使用 lowercase
分词器效率更高,因为分词器操作在一个步骤中完成。
使用示例
以下示例请求创建一个名为 my-lowercase-index
的新索引,并使用 lowercase
分词器配置一个分析器。
PUT /my-lowercase-index
{
"settings": {
"analysis": {
"tokenizer": {
"my_lowercase_tokenizer": {
"type": "lowercase"
}
},
"analyzer": {
"my_lowercase_analyzer": {
"type": "custom",
"tokenizer": "my_lowercase_tokenizer"
}
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /my-lowercase-index/_analyze
{
"analyzer": "my_lowercase_analyzer",
"text": "This is a Test. OpenSearch 123!"
}
响应包含生成的词元
{
"tokens": [
{
"token": "this",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 0
},
{
"token": "is",
"start_offset": 5,
"end_offset": 7,
"type": "word",
"position": 1
},
{
"token": "a",
"start_offset": 8,
"end_offset": 9,
"type": "word",
"position": 2
},
{
"token": "test",
"start_offset": 10,
"end_offset": 14,
"type": "word",
"position": 3
},
{
"token": "opensearch",
"start_offset": 16,
"end_offset": 26,
"type": "word",
"position": 4
}
]
}