空格分析器
编辑空格分析器
编辑whitespace
分析器会在遇到空格字符时将文本分解为词项。
示例输出
编辑resp = client.indices.analyze( analyzer="whitespace", text="The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.", ) print(resp)
response = client.indices.analyze( body: { analyzer: 'whitespace', text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone." } ) puts response
const response = await client.indices.analyze({ analyzer: "whitespace", text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.", }); console.log(response);
POST _analyze { "analyzer": "whitespace", "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone." }
上面的句子会产生以下词项
[ The, 2, QUICK, Brown-Foxes, jumped, over, the, lazy, dog's, bone. ]
配置
编辑whitespace
分析器不可配置。
定义
编辑它由以下部分组成
- 分词器
如果需要自定义 whitespace
分析器,则需要将其重新创建为 custom
分析器并进行修改,通常是通过添加词项过滤器。这将重新创建内置的 whitespace
分析器,您可以将其用作进一步自定义的起点。
resp = client.indices.create( index="whitespace_example", settings={ "analysis": { "analyzer": { "rebuilt_whitespace": { "tokenizer": "whitespace", "filter": [] } } } }, ) print(resp)
response = client.indices.create( index: 'whitespace_example', body: { settings: { analysis: { analyzer: { rebuilt_whitespace: { tokenizer: 'whitespace', filter: [] } } } } } ) puts response
const response = await client.indices.create({ index: "whitespace_example", settings: { analysis: { analyzer: { rebuilt_whitespace: { tokenizer: "whitespace", filter: [], }, }, }, }, }); console.log(response);