简体   繁体   English

match_phrase查询的模糊行为

[英]Fuzziness behavior on a match_phrase query

Days ago I got this "problem". 几天前,我遇到了这个“问题”。 I was running a match_phrase query in my index. 我在索引中运行match_phrase查询。 Everything was as expected, until I did the same search with a multiple words nouns (before I was using single word nouns, eg: university). 一切都按预期进行,直到我对多个单词名词进行了相同的搜索(在我使用单个单词名词之前,例如:大学)。 I made one misspelling and the search did not work (not found), if I removed a word (let's say the one that was spelled correctly), the search work (found). 我拼错了一个单词,但搜索没有成功(找不到),如果我删除了一个单词(假设拼写正确的单词),搜索工作(找到了)。

Here there are the example I made: 这里有我做的例子:

The settings 设定

PUT index1
{
  "mappings": {
    "myType": {
      "properties": {
        "field1": {
          "type": "string",
          "analyzer": "standard"
        }
      }
    }
  }
}

POST index1/myType/1
{
  "field1": "Commercial Banks"
}

Case 1: Single noun search 情况1:单名词搜索

GET index1/myType/_search
{
  "query": {
    "match": {
      "field1": {
        "type": "phrase", 
        "query": "comersial",
        "fuzziness": "AUTO"
      }
    }
  }
}

{
  "took": 16,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.19178303,
    "hits": [
      {
        "_index": "index1",
        "_type": "myType",
        "_id": "1",
        "_score": 0.19178303,
        "_source": {
          "field1": "Commercial Banks"
        }
      }
    ]
  }
}

Case 2: Multiple noun search 情况2:多个名词搜索

GET index1/myType/_search
{
  "query": {
    "match": {
      "field1": {
        "type": "phrase", 
        "query": "comersial banks",
        "fuzziness": "AUTO"
      }
    }
  }
}

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

So, in the second case, why am I not finding the document when performing the match_phrase query? 因此,在第二种情况下,为什么在执行match_phrase查询时找不到文档? Is there something I am missing? 我有什么想念的吗? Those result just make doubt about what I know. 这些结果令人怀疑我所知道的。 Am I using the fuzzy search incorrectly? 我是否使用了模糊搜索? I'm not sure if this is a problem, or I'm the one who do not understand the behavior. 我不确定这是否是问题,还是我不了解该行为。

Many thanks in advance for reading my question. 在此先非常感谢您阅读我的问题。 I hope you can help me with this. 希望您能帮到我。

Fuzziness is not supported in phrase queries. 词组查询不支持模糊性。

Currently, ES is silent about it, ie it allows you to specify the parameter but doesn't warn you that it is not supported. 当前,ES对此保持沉默,即,它允许您指定参数,但不会警告您不支持该参数。 A pull request (#18322) (related to issue #7764 ) exists that will remedy to this problem. 存在可以解决此问题的请求(#18322) (与问题#7764有关 )。 Once merged into ES 5, this query will error out. 一旦合并到ES 5中,此查询将出错。

In the breaking changes document for 5.0, we can see that this won't be supported: 在5.0的重大更改文档中,我们可以看到它不受支持:

The multi_match query will fail if fuzziness is used for cross_fields , phrase or phrase_prefix type. 如果将cross_fieldsphrasephrase phrase_prefix类型使用fuzzinessmulti_match查询将失败。 This parameter was undocumented and silently ignored before for these types of multi_match . 对于这些类型的multi_match此参数之前没有记录,并且已被静默忽略。

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

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