ElasticSearch:为什么 query_string 不区分大小写而通配符区分大小写?

ElasticSearch: why is query_string case insensitive and wildcard case sensitive?

为什么当您对不区分大小写的字段执行 query_string 查询而通配符查询区分大小写时?我本以为两者的行为会相似。

这个query_string查询returns结果

{
  "query": {
    "bool" : {
      "must" : [ {
        "query_string" : {
          "query" : "name:*HILTON*"
        }
      } ]
    }
  }
}

因为这个通配符查询没有

{
  "query": {
    "bool" : {
      "must" : [{
        "wildcard" : {
          "name" : "*HILTON*"
        }
      } ]
    }
  }
}

这是因为 Wild card query 适用于 not analyzed 个字段。

根据文档:

The prefix, wildcard, and regexp queries operate on terms. If you use them to query an analyzed field, they will examine each term in the field, not the field as a whole.

Wild card query matches documents that have fields matching a wildcard expression (not analyzed).