elasticsearch查询时不区分大小写

为什么80%的码农都做不了架构师?>>>   hot3.png

在es查询时不区分大小写,可以让查询更方便,具体设置如下:

{
  "settings": {
    "index": {
      "number_of_shards": "8",
      "number_of_replicas": "1"
    },
	"analysis": {
      "analyzer": {
        "caseSensitive": {
          "filter": "lowercase",
          "type": "custom",
          "tokenizer": "keyword" 
        }
      }
    }
  },
  "mappings": {
    "personInfo": {
      "properties": {        
		"userName":{
		  "type":"string",
		  "analyzer": "caseSensitive",
                  "search_analyzer": "caseSensitive"
		}
      }
    }
  }
}

"filter": "lowercase"都转为小写去查询,"tokenizer": "keyword" 将输入的内容做为一个整体进行分词

转载于:https://my.oschina.net/sucre/blog/1627153

你可能感兴趣的:(大数据,java,python)