如何使用 Mongoosastic 处理 ElasticSearch 自动完成中的非拉丁字符?
How to approach non-latin characters in ElasticSearch autocompletion with Mongoosastic?
使用 es.search({size: 0, suggest: ...}
在可以具有非拉丁变音符号(重音字符,如 â、ê 等)的字段上使用完成映射,自动完成工作正常。
我正在使用 mongoosastic
创建映射。我需要能够使用 asciifolding
之类的内容来获取建议或在响应中添加其他字段。
我有那些字段:
name
有变音符号的。
nameSearch
这是 name
拉丁化的(没有 diacritics/accented 个字符)。
我需要的是在 name
上继续完成建议,但将 a
与 â
相同(反之亦然)。
在我需要的回复中name
。不是 nameSearch
.
我又遇到了这个问题,这次没有mongoosastic
。答案是在索引查询中包含 settings
字段(在 mongoosastic
中,您可以在使用自定义映射时添加它)。
settings: {
analysis: {
analyzer: {
folding: {
tokenizer: 'standard',
filter: ['lowercase', 'custom_asciifolding'],
},
},
filter: {
custom_asciifolding: {
type: 'asciifolding',
preserve_original: true,
},
},
},
}
使用 es.search({size: 0, suggest: ...}
在可以具有非拉丁变音符号(重音字符,如 â、ê 等)的字段上使用完成映射,自动完成工作正常。
我正在使用 mongoosastic
创建映射。我需要能够使用 asciifolding
之类的内容来获取建议或在响应中添加其他字段。
我有那些字段:
name
有变音符号的。nameSearch
这是name
拉丁化的(没有 diacritics/accented 个字符)。
我需要的是在 name
上继续完成建议,但将 a
与 â
相同(反之亦然)。
在我需要的回复中name
。不是 nameSearch
.
我又遇到了这个问题,这次没有mongoosastic
。答案是在索引查询中包含 settings
字段(在 mongoosastic
中,您可以在使用自定义映射时添加它)。
settings: {
analysis: {
analyzer: {
folding: {
tokenizer: 'standard',
filter: ['lowercase', 'custom_asciifolding'],
},
},
filter: {
custom_asciifolding: {
type: 'asciifolding',
preserve_original: true,
},
},
},
}