弹性搜索match_phrase +模糊性 [英] Elastic search match_phrase + fuzziness

查看:67
本文介绍了弹性搜索match_phrase +模糊性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ElasticSearch,并且正在尝试实现match_phrase/string +模糊性,但是似乎这是不可能的(在线没有那么多示例,文档中也没有这种情况).

I am using ElasticSearch and I am trying to implement match_phrase/string + fuzziness but it seems like it is impossible (not that much examples online, no such cases in the documentation).

我需要的是:短语/字符串匹配+模糊性+基于字段的每个值的斜率.

What I need: phrase/string matching + fuzziness + slop based on every value of the field individually.

到目前为止,我已经尝试过(但仍然没有所需的解决方案):

What I've tried so far (and I still don't have a solution I need):

query_string-它具有模糊性和倾斜度.但是,它会通过一个文档通过该字段的所有值收集一个字符串.

query_string - it has fuzziness and slop included. However, it gathers a string through all of the values of the field through one document.

match_phrase-包括倾斜,但没有模糊性.好处是-它会在字段的至少一个值中查找词组匹配,而不是通过文档字段的所有值来收集字符串.

match_phrase - it has slop included, but there is no fuzziness. What is good - it looks for a phrase match in at least one of the values of the field, not gathers the string through all the values of the document's field.

我需要什么:

有人在词组匹配方面有经验,包括ElasticSearch上的模糊性吗?

Anybody has experience on phrase matching including fuzziness on ElasticSearch?

谢谢.

推荐答案

您可以使用

You can make use of Span Queries for this as I've mentioned in the links in the comment section of the question.

您进一步寻找的是一种使用跨度查询来控制模糊性的方法.我已经从

What you further looking for, is a way to control fuzziness using Span Queries. I've taken an example from this SOF answer and rewrote the query as you wanted to manage fuzziness.

POST <your_index_name>
{  
   "query":{  
      "bool":{  
         "must":[  
            {  
               "span_near":{  
                  "clauses":[  
                     {  
                        "span_multi":{  
                           "match":{  
                              "fuzzy":{  
                                 "name":{  
                                    "value":"champions",
                                    "fuzziness":2
                                 }
                              }
                           }
                        }
                     },
                     {  
                        "span_multi":{  
                           "match":{  
                              "fuzzy":{  
                                 "name":{  
                                    "value":"league",
                                    "fuzziness":2
                                 }
                              }
                           }
                        }
                     }
                  ],
                  "slop":0,
                  "in_order":false
               }
            }
         ]
      }
   }
}

希望这会有所帮助!

这篇关于弹性搜索match_phrase +模糊性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆