代码之家  ›  专栏  ›  技术社区  ›  Preston

将一个索引短语与弹性中的fuzzy匹配

  •  0
  • Preston  · 技术社区  · 5 年前

    我在elasticsearch中索引了以下两个条目:

    united states
    united states minor outlying islands
    

    united states :

    united tsates
    unitedstates
    united sates
    

    我试过 span_near 其他问题中建议的方法( here 在这里 美国 united states minor outlying islands .

    我怎么能只匹配 美国 上面提到的条款清单?

    第一次尝试:

    {
       "query":{
          "bool":{
             "must":{
                "match":{
                   "country_name":{
                      "query":"united tsates",
                      "fuzziness":1,
                      "operator": "and"
                   }
                }
             }
          }
       }
    }
    

    尝试 span\U近

    {
       "query":{
          "span_near":{
             "clauses":[
                {
                   "span_multi":{
                      "match":{
                         "fuzzy":{
                            "country_name":{
                               "fuzziness":"1",
                               "value":"united"
                            }
                         }
                      }
                   }
                },
                {
                   "span_multi":{
                      "match":{
                         "fuzzy":{
                            "country_name":{
                               "fuzziness":"1",
                               "value":"tsates"
                            }
                         }
                      }
                   }
                }
             ],
             "slop":0,
             "in_order":"true"
          }
       }
    }
    
    0 回复  |  直到 5 年前
        1
  •  1
  •   Barkha Jain    5 年前

    GET test_index/_search
        {
          "query": {
            "fuzzy": {
              "country_name.keyword": "united tsates"
            }
          }
        }