弹性搜索中通配符和模糊查询一起使用

Pra*_*nav 7 fuzzy-search wildcard elasticsearch

我正在尝试设计一个查询,其中可以一起使用通配符和模糊查询。

据我所知,query_string 用于通配符搜索,而 multi_match 可用于模糊性。

我想要一个将搜索单词的查询:-

“elast”:- 提供elastic 和elasticsearch 的结果。“elasttc”:- 还提供弹性和弹性搜索的结果。

Elasticsearch同时支持通配符和模糊查询??

提前致谢...

Dav*_*orp 5

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "testing"
          }
        },
        {
          "wildcard": {
            "title": "*testing*"
          }
        },
        {
          "fuzzy": {
            "title": "testing"
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}
Run Code Online (Sandbox Code Playgroud)


小智 0

您可以将其与带有通配符的查询字符串一起使用。后缀~AUTO*可以实现模糊前缀查询,也可以使用字段选择,如multi_match查询:

{
    "query": {
        "query_string" : {
            "fields" : ["name^2", "content^1"],
            "query" : "elasttc~AUTO*"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

您也可以AUTO使用数值更改关键字,就像相同的fuzziness参数一样。