1、导出es原mapping
elasticdump --input=http://es01:9200/ index_name_5 --output= index_name_5.json --type=mapping
2、修改mapping信息
【a】备份原mapping
cp index_name_5.json index_name_5.json.bak
【b】在mapping文件中添加需要忽略大小写字段的属性字段
* vim index_name_5.json
* 添加"normalizer":“my_normalizer” (注意:确认要修改的字段type类型是否为keyword,当字段类型为text时,不支持该配置添加)
3、创建备份mapping
curl -XPUT es01:9200/ index_name_5_v1
curl -XPOST es01:9200/ index_name_5_v1/_close
curl -XPUT -H “Content-Type: application/json” es01:9200/ index_name_5_v1/_settings -d ‘{“settings”:{“analysis”:{“normalizer”:{“my_normalizer”:{“type”:“custom”,“filter”:[“lowercase”]}}}}}’
curl -XPOST es01:9200/ index_name_5_v1/_open
elasticdump --input= index_name_5.json --output=http://es01:9200/ index_name_5_v1 --type=mapping
curl -XPOST -H “Content-Type: application/json” es01:9200/_reindex?wait_for_completion=true -d ‘{“source”:{“index”:" index_name_5",“size”: 100},“dest”:{“index”:" index_name_5_v1"}}’
4、对比原mapping与备份mapping的数据条数是否一致
curl -XPOST -H “Content-Type: application/json” es01:9200/ index_name_5_v1/_count
curl -XPOST -H “Content-Type: application/json” es01:9200/ index_name_5/_count
5、重建旧mapping
curl -XPOST es01:9200/ index_name_5/_close
curl -XDELETE es01:9200/ index_name_5
curl -XPUT es01:9200/ index_name_5
curl -XPOST es01:9200/ index_name_5/_close
curl -XPUT -H “Content-Type: application/json” es01:9200/ index_name_5/_settings -d ‘{“settings”:{“analysis”:{“normalizer”:{“my_normalizer”:{“type”:“custom”,“filter”:[“lowercase”]}}}}}’
curl -XPOST es01:9200/ index_name_5/_open
elasticdump --input= index_name_5.json --output=http://es01:9200/ index_name_5 --type=mapping
curl -XPOST -H “Content-Type: application/json” es01:9200/_reindex?wait_for_completion=true -d ‘{“source”:{“index”:" index_name_5_v1",“size”: 100},“dest”:{“index”:" index_name_5"}}’