使用模糊性是否会在 simple_query_string 中禁用前缀搜索
Does using fuzziness disable prefix search in a simple_query_string
当使用 simple_query_string
和前缀运算符 *
和 模糊值 ~N
在同一个词上时,前缀搜索似乎被禁用。
{
"query": {
"simple_query_string": {
"query": "Abcd*~2",
"fields": ["name"]
}
}
}
很明显,只要您将模糊度设置为 0 并且查询变为 Abcd*~0
,那么就没有前缀搜索,也没有模糊度。
文档中没有提到这一点,所以我不确定我是否做错了。
我试过:
- 交换运算符顺序:
Abcd~2*
——在_explain
中,这引入了模糊性变化但省略了前缀运算符
- 使用括号作为优先级:
(Abcd*)~2
-- 在 _explain
中使用前缀但省略模糊运算符1
- 复制单词:
(Abcd* Abcd~2)
-- 这行得通,它显然显示了两个查询的重聚,而不是两个效果的组合2.
1 我假设在这种情况下 ~2
不应被解释为 SLOP 运算符,因为没有短语(没有引号)。
2 我可以理解,合成这些效果可能会产生太多可能的变体——模糊添加 50 个变体,然后对每个变体进行前缀搜索,
根据查询字符串 docs
Mixing fuzzy and wildcard operators is not supported. When mixed, one
of the operators is not applied. For example, you can search for app~1
(fuzzy) or app* (wildcard), but searches for app*~1 do not apply the
fuzzy operator (~1).
它会考虑通配符或模糊,以先到者为准。
对于 Abcd~2* 只是返回所有文件
当使用 simple_query_string
和前缀运算符 *
和 模糊值 ~N
在同一个词上时,前缀搜索似乎被禁用。
{
"query": {
"simple_query_string": {
"query": "Abcd*~2",
"fields": ["name"]
}
}
}
很明显,只要您将模糊度设置为 0 并且查询变为 Abcd*~0
,那么就没有前缀搜索,也没有模糊度。
文档中没有提到这一点,所以我不确定我是否做错了。
我试过:
- 交换运算符顺序:
Abcd~2*
——在_explain
中,这引入了模糊性变化但省略了前缀运算符 - 使用括号作为优先级:
(Abcd*)~2
-- 在_explain
中使用前缀但省略模糊运算符1 - 复制单词:
(Abcd* Abcd~2)
-- 这行得通,它显然显示了两个查询的重聚,而不是两个效果的组合2.
1 我假设在这种情况下 ~2
不应被解释为 SLOP 运算符,因为没有短语(没有引号)。
2 我可以理解,合成这些效果可能会产生太多可能的变体——模糊添加 50 个变体,然后对每个变体进行前缀搜索,
根据查询字符串 docs
Mixing fuzzy and wildcard operators is not supported. When mixed, one of the operators is not applied. For example, you can search for app~1 (fuzzy) or app* (wildcard), but searches for app*~1 do not apply the fuzzy operator (~1).
它会考虑通配符或模糊,以先到者为准。 对于 Abcd~2* 只是返回所有文件