ASCII 折叠分词器
编辑ASCII 折叠分词器
编辑将不在基本拉丁Unicode块(前127个ASCII字符)中的字母、数字和符号字符转换为其ASCII等效字符(如果存在)。例如,该过滤器将à
更改为a
。
此过滤器使用 Lucene 的 ASCIIFoldingFilter。
示例
编辑以下 分析 API 请求使用asciifolding
过滤器去除açaí à la carte
中的变音符号。
resp = client.indices.analyze( tokenizer="standard", filter=[ "asciifolding" ], text="açaí à la carte", ) print(resp)
response = client.indices.analyze( body: { tokenizer: 'standard', filter: [ 'asciifolding' ], text: 'açaí à la carte' } ) puts response
const response = await client.indices.analyze({ tokenizer: "standard", filter: ["asciifolding"], text: "açaí à la carte", }); console.log(response);
GET /_analyze { "tokenizer" : "standard", "filter" : ["asciifolding"], "text" : "açaí à la carte" }
过滤器生成以下标记:
[ acai, a, la, carte ]
添加到分析器
编辑以下 创建索引 API 请求使用asciifolding
过滤器配置新的 自定义分析器。
resp = client.indices.create( index="asciifold_example", settings={ "analysis": { "analyzer": { "standard_asciifolding": { "tokenizer": "standard", "filter": [ "asciifolding" ] } } } }, ) print(resp)
response = client.indices.create( index: 'asciifold_example', body: { settings: { analysis: { analyzer: { standard_asciifolding: { tokenizer: 'standard', filter: [ 'asciifolding' ] } } } } } ) puts response
const response = await client.indices.create({ index: "asciifold_example", settings: { analysis: { analyzer: { standard_asciifolding: { tokenizer: "standard", filter: ["asciifolding"], }, }, }, }, }); console.log(response);
PUT /asciifold_example { "settings": { "analysis": { "analyzer": { "standard_asciifolding": { "tokenizer": "standard", "filter": [ "asciifolding" ] } } } } }
可配置参数
编辑-
preserve_original
- (可选,布尔值) 如果为
true
,则同时输出原始标记和折叠后的标记。默认为false
。
自定义
编辑要自定义asciifolding
过滤器,请复制它以创建新自定义分词器的基础。您可以使用其可配置参数修改过滤器。
例如,以下请求创建一个自定义asciifolding
过滤器,并将preserve_original
设置为true:
resp = client.indices.create( index="asciifold_example", settings={ "analysis": { "analyzer": { "standard_asciifolding": { "tokenizer": "standard", "filter": [ "my_ascii_folding" ] } }, "filter": { "my_ascii_folding": { "type": "asciifolding", "preserve_original": True } } } }, ) print(resp)
response = client.indices.create( index: 'asciifold_example', body: { settings: { analysis: { analyzer: { standard_asciifolding: { tokenizer: 'standard', filter: [ 'my_ascii_folding' ] } }, filter: { my_ascii_folding: { type: 'asciifolding', preserve_original: true } } } } } ) puts response
const response = await client.indices.create({ index: "asciifold_example", settings: { analysis: { analyzer: { standard_asciifolding: { tokenizer: "standard", filter: ["my_ascii_folding"], }, }, filter: { my_ascii_folding: { type: "asciifolding", preserve_original: true, }, }, }, }, }); console.log(response);
PUT /asciifold_example { "settings": { "analysis": { "analyzer": { "standard_asciifolding": { "tokenizer": "standard", "filter": [ "my_ascii_folding" ] } }, "filter": { "my_ascii_folding": { "type": "asciifolding", "preserve_original": true } } } } }