原文地址: https://www.elastic.co/guide/cn/elasticsearch/guide/current/fuzzy-match-query.html, 版权归 www.elastic.co 所有
英文版地址: https://www.elastic.co/guide/en/elasticsearch/guide/current/fuzzy-match-query.html
英文版地址: https://www.elastic.co/guide/en/elasticsearch/guide/current/fuzzy-match-query.html
请注意:
本书基于 Elasticsearch 2.x 版本,有些内容可能已经过时。
本书基于 Elasticsearch 2.x 版本,有些内容可能已经过时。
模糊匹配查询 (Fuzzy match Query)edit
match 查询支持开箱即用的模糊匹配:
GET /my_index/my_type/_search
{
"query": {
"match": {
"text": {
"query": "SURPRIZE ME!",
"fuzziness": "AUTO",
"operator": "and"
}
}
}
}
查询字符串首先进行分析,会产生词项 surprize, me ,并且每个词项根据指定的 fuzziness 进行模糊化。
同样, multi_match 查询也支持 fuzziness ,但只有当执行查询时类型是 best_fields 或者 most_fields :
GET /my_index/my_type/_search
{
"query": {
"multi_match": {
"fields": [ "text", "title" ],
"query": "SURPRIZE ME!",
"fuzziness": "AUTO"
}
}
}
match 和 multi_match 查询都支持 prefix_length 和 max_expansions 参数。
模糊性(Fuzziness)只能在 match 和 multi_match 查询中使用。不能使用在短语匹配(phrase matching)、常用词项(common terms) 或 cross_fields匹配中。