ElasticSearch-查询 忽略大小写 完全匹配查询

创建索引 忽略大小写

PUT /ecommerce
{
  "settings": {
    "analysis": {
      "normalizer": {
        "my_normalizer": {
          "type": "custom",
          "char_filter": [],
          "filter": ["lowercase", "asciifolding"]
        }
      }
    }
  },
  "mappings": {
    "product": {
      "properties": {
        "producer": {
          "type": "keyword",
          "normalizer": "my_normalizer"
        }
      }
    }
  }
}

插入几条数据

PUT /ecommerce/product/1
{
    "producer" :    "Special"
}

PUT /ecommerce/product/4
{

    "producer" :      "special yagao producer"
}
PUT /ecommerce/product/5
{

    "producer" :      "sPecIal yagao producer"
}

完全匹配查询

GET /ecommerce/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "producer": {
              "value": "special"
            }
          }
        }
      ]
    }
  }
}

https://www.elastic.co/guide/en/elasticsearch/reference/6.0/normalizer.html

你可能感兴趣的:(elasticsearch)