Elastic Search 匹配短语查询 -> 输出不可预测

Sah*_*pta 5 phrase elasticsearch elasticsearch-query

示例文档

{
  "id": 5,
  "title": "Quick Brown fox jumps over the lazy dog",
  "genre": [
    "fiction"
  ]
}
Run Code Online (Sandbox Code Playgroud)

映射

{
  "movies" : {
    "mappings" : {
      "properties" : {
        "genre" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "id" : {
          "type" : "long"
        },
        "title" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Query1:先前共享的文档中的结果

{
 "query": {
   "match_phrase": {
     "title": {
       "query": "fox quick over", "slop": 3
     }
   }
 } 
}
Run Code Online (Sandbox Code Playgroud)

查询 2:没有结果

{
 "query": {
   "match_phrase": {
     "title": {
       "query": "over fox quick", "slop": 3
     }
   }
 } 
}
Run Code Online (Sandbox Code Playgroud)

我期望在 query2 中而不是在查询 1 中得到结果。

jas*_*hal 3

斜坡

为了使查询和文档匹配而需要移动术语的次数。

切换词序需要两次编辑/步骤

下面是文字的移动

查询1:

            位置 1 位置 2 位置 3 位置 4 位置 5 位置 6 位置 7 位置 8
-------------------------------------------------- ------------------------------------------------
医生:敏捷的棕色狐狸跳过了那只懒狗
-------------------------------------------------- ------------------------------------------------
查询:狐狸快过
Slop 1:狐狸|快速结束                                       
坡道 2:快速越过
坡道 3:快速越过

总共步骤 3

查询2:

            位置 1 位置 2 位置 3 位置 4 位置 5 位置 6 位置 7 位置 8
-------------------------------------------------- ------------------------------------------------
医生:敏捷的棕色狐狸跳过了那只懒狗
-------------------------------------------------- ------------------------------------------------
查询:过狐快
坡度 1:越过狐狸|快速            
Slop 2:快速|超过狐狸           
Slop 3:快速超越狐狸       
Slop 4:快速结束|狐狸      
坡道 5:快速越过
坡道 6:快速越过

总步骤 6