我正在尝试运行“模糊”query_string 搜索,您知道可能出了什么问题吗? Fuzziness参数本身对query_string有效,不会抛出异常。
找到一个结果:
{
"query": {
"bool": {
"should": {
"query_string": {
"default_field": "title",
"query": "index"
}
}
}
}
}
找不到任何东西:
{
"query": {
"bool": {
"should": {
"query_string": {
"default_field": "title",
"query": "indexa",
"fuzziness": 9000
}
}
}
}
}
最佳答案
对于查询字符串,您必须显式使用 "fuzzy operator" ~
。
尝试:
"query_string": {
"default_field": "title",
"query": "indexa~",
"fuzziness": "AUTO"
}
或者,您可以使用 fuzzy match query如果您知道要搜索的字段并且不需要查询字符串功能(例如允许用户使用 AND
或 OR
等运算符或引入自定义增强等)
"match": {
"title": {
"query": "indexa",
"fuzziness": "AUTO"
}
}
另请注意,在这两种情况下,模糊性
only accepts the values 1
, 2
or AUTO
,因此 9000 不是有效值。
关于elasticsearch - query_string 的模糊性被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36566353/