简体   繁体   English

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

[英]ElasticSearch: why is query_string case insensitive and wildcard case sensitive?

Why is it when you do a query_string query on a field it's case insensitive and a wildcard query is case sensitive? 为什么在对字段执行query_string查询时不区分大小写,而通配符查询却区分大小写? I would've thought the two would behave similarly. 我以为两者的行为会相似。

This query_string query returns results 此query_string查询返回结果

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

Where as this wildcard query doesn't 这个通配符查询不在哪里

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

This is because Wild card query works for not analyzed fields. 这是因为通配符查询适用于not analyzed字段。

As per the documentation: 根据文档:

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) . 通配符查询匹配具有匹配通配符表达式(未分析)的字段的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM