模糊性在 Elasticsearch 中的行为不符合预期
Fuzziness not behaving as expected in Elasticsearch
我正在尝试为我在 Elasticsearch 中进行的项目测试几个测试用例。模糊查询给出的结果对于特定情况来说是令人困惑的:- 在搜索 Mall 关键字时,模糊性 2 应用于多匹配查询,它也匹配 Mile.
As per fuzziness documentation :-
=> 0 edits are allowed for string length is 0-2 .
=> 1 edit is allowed for string length is 3-5.
=> 2 edits are allowed for string length greater than 5.
如果是这种情况,为什么 MILE 与 MALL 匹配,因为按照逻辑,只允许一次编辑,如果我们看到 MALL->MILE 我们需要 2 次编辑。 Elasticsearch 是否按预期运行,或者我在这里遗漏了什么。 我正在对字段使用简单的空白分析器并使用
进行查询 { "query": {
"multi_match": {
"query": "mall",
"fields": [
"name"
],
"fuzziness": 2
} }}
您突出显示的文档仅适用于您指定 "fuzziness": "AUTO"
时,否则如果您指定一个正常数字(0、1 或 2),则会考虑该数字(在您的情况下为 2 )