无法在 ElasticSearch 中将字母数字字符串与 query_string 内的通配符匹配

Unable to match alphanumeric string with wildcard inside query_string in ElasticSearch

我正在使用以下映射:

"letters": {
    "mappings": {
       "letter": {
          "properties": {
            "destCode": {
               "type": "string",
               "index": "not_analyzed"
            },
            "tag": {
               "type": "string",
               "index": "not_analyzed"
            }
         }
      }
   }
}

我的文档包含两个字段:

以下query_String(我知道通配符不好):

"query": {
    "query_string": {
        "default_field": "destCode",
        "query": "*604"
    }   
} 

正确匹配 0144604、4521604 destCode 值。

但它不适用于标记字段,例如查询:

"query": {
    "query_string": {
        "default_field": "tag",
        "query": "CDG*" 
    }   
} 

不匹配值:CDG711892、CDG88978,我也尝试了小写的 cdg* 但没有成功。

在映射中,您将字段设置为未分析,因为当您索引数据时,elasticsearch 不会分析它,因为如果您将数据索引为小写,如果您搜索大写,您将不会一无所获。 删除

index": "not_analyzed

它会起作用