关键词分析器
编辑关键词分析器
编辑keyword
分析器是一个“无操作”分析器,它将整个输入字符串作为单个词元返回。
示例输出
编辑resp = client.indices.analyze( analyzer="keyword", text="The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.", ) print(resp)
response = client.indices.analyze( body: { analyzer: 'keyword', text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone." } ) puts response
const response = await client.indices.analyze({ analyzer: "keyword", text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.", }); console.log(response);
POST _analyze { "analyzer": "keyword", "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. ]
配置
编辑keyword
分析器不可配置。
定义
编辑keyword
分析器由以下部分组成
- 分词器
如果您需要自定义 keyword
分析器,那么您需要将其重新创建为 custom
分析器并对其进行修改,通常是通过添加词元过滤器。 通常,当您需要不被拆分成词元的字符串时,您应该优先选择 关键词类型,但以防您需要它,这将重新创建内置的 keyword
分析器,您可以将其用作进一步自定义的起点
resp = client.indices.create( index="keyword_example", settings={ "analysis": { "analyzer": { "rebuilt_keyword": { "tokenizer": "keyword", "filter": [] } } } }, ) print(resp)
response = client.indices.create( index: 'keyword_example', body: { settings: { analysis: { analyzer: { rebuilt_keyword: { tokenizer: 'keyword', filter: [] } } } } } ) puts response
const response = await client.indices.create({ index: "keyword_example", settings: { analysis: { analyzer: { rebuilt_keyword: { tokenizer: "keyword", filter: [], }, }, }, }, }); console.log(response);