简体   繁体   English

弹性搜索match_phrase +模糊性

[英]Elastic search match_phrase + fuzziness

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

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 - it has fuzziness and slop included. query_string-它具有模糊性和倾斜性。 However, it gathers a string through all of the values of the field through one document. 但是,它将通过一个文档收集该字段的所有值的字符串。

match_phrase - it has slop included, but there is no fuzziness. match_phrase-包括斜率,但没有模糊性。 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. 好处是-它会在字段的至少一个值中查找词组匹配,而不是通过文档字段的所有值来收集字符串。

What I need: 我需要的:

Anybody has experience on phrase matching including fuzziness on ElasticSearch? 任何人都有短语匹配方面的经验,包括ElasticSearch上的模糊性吗?

Thanks in advance. 提前致谢。

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. 我已经从这个SOF答案中举了一个例子,并在您想要管理模糊性时重写了查询。

Query 询问

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
               }
            }
         ]
      }
   }
}

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM