0

几天前,我遇到了这个“问题”。match_phrase我在我的索引中运行一个查询。一切都如预期的那样,直到我对多个词的名词进行了相同的搜索(在我使用单个词的名词之前,例如:大学)。我犯了一个拼写错误并且搜索不起作用(未找到),如果我删除了一个单词(假设拼写正确的单词),则搜索工作(找到)。

这里有我做的例子:

设置

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

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

案例一:单名词检索

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

案例 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": []
  }
}

那么,在第二种情况下,为什么我在执行match_phrase查询时没有找到文档?有什么我想念的吗?这些结果只是对我所知道的产生怀疑。我是否错误地使用了模糊搜索?我不确定这是否是一个问题,或者我是不理解这种行为的人。

非常感谢您阅读我的问题。我希望你能帮我解决这个问题。

4

1 回答 1

4

短语查询不支持模糊性。

目前,ES 对此保持沉默,即它允许您指定参数但不会警告您不支持它。存在一个拉取请求 (#18322)(与问题 #7764相关)可以解决此问题。一旦合并到 ES 5,这个查询就会出错。

在 5.0 的重大更改文档中,我们可以看到这将不受支持:

如果用于、或类型,multi_match查询将失败。对于这些类型的.fuzzinesscross_fieldsphrasephrase_prefixmulti_match

于 2016-05-17T03:43:31.183 回答