幾天前,我得到了這個「問題」。我在索引中運行match_phrase
查詢。一切都如預期,直到我用多個單詞名詞進行同樣的搜索(在我使用單個單詞名詞之前,例如:大學)。如果我刪除了一個單詞(比如說拼寫正確的單詞),那麼搜索工作(找到)會導致拼寫錯誤,並且搜索不起作用(未找到)。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
查詢時找不到文檔?有什麼我失蹤? 這些結果只是讓我懷疑我所知道的。 我使用模糊搜索嗎?我不確定這是否是一個問題,或者我是不瞭解這種行爲的人。
非常感謝提前閱讀我的問題。我希望你能幫助我。