簡體   English   中英

match_phrase查詢的模糊行為

[英]Fuzziness behavior on a match_phrase query

幾天前,我遇到了這個“問題”。 我在索引中運行match_phrase查詢。 一切都按預期進行,直到我對多個單詞名詞進行了相同的搜索(在我使用單個單詞名詞之前,例如:大學)。 我拼錯了一個單詞,但搜索沒有成功(找不到),如果我刪除了一個單詞(假設拼寫正確的單詞),搜索工作(找到了)。

這里有我做的例子:

設定

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

情況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查詢時找不到文檔? 我有什么想念的嗎? 這些結果令人懷疑我所知道的。 我是否使用了模糊搜索? 我不確定這是否是問題,還是我不了解該行為。

在此先非常感謝您閱讀我的問題。 希望您能幫到我。

詞組查詢不支持模糊性。

當前,ES對此保持沉默,即,它允許您指定參數,但不會警告您不支持該參數。 存在可以解決此問題的請求(#18322) (與問題#7764有關 )。 一旦合並到ES 5中,此查詢將出錯。

在5.0的重大更改文檔中,我們可以看到它不受支持:

如果將cross_fieldsphrasephrase phrase_prefix類型使用fuzzinessmulti_match查詢將失敗。 對於這些類型的multi_match此參數之前沒有記錄,並且已被靜默忽略。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM