首页 > 解决方案 > Elasticsearch 通配符查询结果命中也发生变化

问题描述

Elasticsearch 版本:7.10.2 目前,我在新版本中遇到了一个关于通配符类型的通配符查询的奇怪问题。我使用 DSL 查询如下

{"_source":"brand_name","query":{"wildcard":{"brand_name":{"value":"*wUg*"}}},"sort":[{"shop_id":{"order":"desc"}}]}

命中结果响应 在此处输入图像描述 在此处 输入图像描述

但是相同的查询总命中数总是每次都在变化,我阅读了官方文档并没有找到任何答案。那么有没有高手可以帮忙检查一下这个问题?索引设置

{
  "wildcard_query_1000w" : {
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "include" : {
              "_tier_preference" : "data_content"
            }
          }
        },
        "number_of_shards" : "3",
        "provided_name" : "wildcard_query_1000w",
        "creation_date" : "1614589156629",
        "analysis" : {
          "normalizer" : {
            "lowerasciinormalizer" : {
              "filter" : [
                "lowercase",
                "asciifolding"
              ],
              "type" : "custom"
            }
          },
          "analyzer" : {
            "my_analyzer" : {
              "filter" : [
                "lowercase",
                "asciifolding"
              ],
              "tokenizer" : "standard"
            }
          }
        },
        "number_of_replicas" : "1",
        "uuid" : "SL4M3NLySB6f0MPVhM-v7A",
        "version" : {
          "created" : "7100299"
        }
      }
    }
  }
}

索引映射

{
  "wildcard_query_1000w" : {
    "mappings" : {
      "dynamic_templates" : [
        {
          "string" : {
            "match_mapping_type" : "string",
            "mapping" : {
              "normalizer" : "lowerasciinormalizer",
              "type" : "wildcard"
            }
          }
        }
      ],
      "properties" : {
        "brand_name" : {
          "type" : "wildcard"
        },
        "entity_id" : {
          "type" : "keyword"
        },
        "shop_id" : {
          "type" : "long"
        },
        "ssp_doc_ts" : {
          "type" : "long"
        },
        "status" : {
          "type" : "long"
        },
        "toc" : {
          "properties" : {
            "loyalty" : {
              "properties" : {
                "tier" : {
                  "type" : "keyword"
                }
              }
            }
          }
        }
      }
    }
  }
}

标签: elasticsearch

解决方案


推荐阅读