elasticsearch 匹配短语查询中的模糊行为,elasticsearch,elasticsearch-2.0,elasticsearch,elasticsearch 2.0" /> elasticsearch 匹配短语查询中的模糊行为,elasticsearch,elasticsearch-2.0,elasticsearch,elasticsearch 2.0" />

elasticsearch 匹配短语查询中的模糊行为

elasticsearch 匹配短语查询中的模糊行为,elasticsearch,elasticsearch-2.0,elasticsearch,elasticsearch 2.0,几天前我遇到了这个“问题”。我在索引中运行了一个match\u短语查询。一切都如期而至,直到我用多个词名词做了同样的搜索(在我使用单词名词之前,例如:university)。我犯了一个拼写错误,搜索不起作用(未找到),如果我删除了一个单词(比如拼写正确的单词),搜索就起作用(找到) 下面是我举的例子: 设置 PUT index1 { "mappings": { "myType": { "properties": { "field1": {

几天前我遇到了这个“问题”。我在索引中运行了一个
match\u短语
查询。一切都如期而至,直到我用多个词名词做了同样的搜索(在我使用单词名词之前,例如:university)。我犯了一个拼写错误,搜索不起作用(未找到),如果我删除了一个单词(比如拼写正确的单词),搜索就起作用(找到)

下面是我举的例子:

设置

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

POST index1/myType/1
{
  "field1": "Commercial Banks"
}
案例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"
        }
      }
    ]
  }
}
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": []
  }
}
案例2:多名词搜索

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"
        }
      }
    ]
  }
}
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\u短语
查询时找不到文档?我有什么遗漏吗? 这些结果让我对我所知道的产生了怀疑。 我是否错误地使用了模糊搜索?我不确定这是否是一个问题,或者是我不了解这种行为


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

短语查询不支持模糊性

目前,ES对此保持沉默,即它允许您指定参数,但不会警告您不支持该参数。存在一个(与相关的)解决此问题的方法。一旦合并到ES 5中,此查询将出错

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

如果对
交叉字段
短语
短语前缀
类型使用
模糊性
,则
多重匹配
查询将失败。对于这些类型的
multi\u match
,此参数以前未记录且被静默忽略


短语查询中不支持模糊性

目前,ES对此保持沉默,即它允许您指定参数,但不会警告您不支持该参数。存在一个(与相关的)解决此问题的方法。一旦合并到ES 5中,此查询将出错

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

如果对
交叉字段
短语
短语前缀
类型使用
模糊性
,则
多重匹配
查询将失败。对于这些类型的
multi\u match
,此参数以前未记录且被静默忽略