先给以前的index加上别名,并且程序里面也修改一下查询index_execution改为查询index_execution_active
curl -XPUT http://15.99.72.167:9200/index_execution/_alias/index_execution_active
然后新建一个索引,如下所示,其中最关键的是新增了标红的部分的normalizer 这是taskcode和tasktitle这2个字段能够不区分大小写的关键
curl -XDELETE http://15.99.72.167:9200/index_execution_20200414
curl -XPUT http://15.99.72.167:9200/index_execution_20200414 -d '
{
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "0"
},
"analysis": {
"normalizer": {
"lowercase": {
"type": "custom",
"filter": [
"lowercase"
]
}
}
}
}
}
'
curl -XPUT http://15.99.72.167:9200/index_execution_20200414/_mapping/type_execution?pretty -d '{
"properties": {
"owner": {
"type": "keyword"
},
"assignner": {
"type": "text"
},
"completion": {
"type": "double"
},
"pass": {
"type": "text"
},
"taskcode": {
"type": "keyword",
"normalizer": "lowercase"
},
"tester": {
"type": "keyword"
},
"refobs": {
"type": "text"
},
"testsite": {
"type": "integer"
},
"startdate": {
"format": "yyyy/MM/dd",
"type": "date"
},
"platform": {
"type": "keyword"
},
"categoryb": {
"type": "text"
},
"categoryc": {
"type": "text"
},
"fail": {
"type": "text"
},
"total": {
"type": "text"
},
"enddate": {
"format": "yyyy/MM/dd",
"type": "date"
},
"na": {
"type": "text"
},
"categorya": {
"type": "text"
},
"tasktitle": {
"type": "keyword",
"normalizer": "lowercase"
},
"block": {
"type": "text"
},
"id": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"newobs": {
"type": "text"
},
"taskExecutionIntancelistViews": {
"properties": {
"completion": {
"type": "float"
},
"fail": {
"type": "long"
},
"instanceCode": {
"type": "keyword"
},
"total": {
"type": "long"
},
"na": {
"type": "long"
},
"instanceName": {
"type": "keyword"
},
"pass": {
"type": "long"
},
"tester": {
"type": "text"
},
"block": {
"type": "long"
},
"refobs": {
"type": "long"
},
"newobs": {
"type": "long"
},
"platform": {
"type": "text"
}
}
},
"status": {
"type": "integer"
}
}
}'
建好新的索引后,用postman或者curl 进行_reindex 操作
curl -XPOST http://15.99.72.167:9200/_reindex -d '
{
"source": {
"index": "index_execution"
},
"dest": {
"index": "index_execution_20200414"
}
}
'
等新索引reindex完成后,通过alias把使用的索引切换到新建的不区分大小写的 index_execution_20200414 上,完成不区分大小写的问题解决
curl -XPOST http://15.99.72.167:9200/_aliases -d '
{
"actions": [
{ "remove": { "index": "index_execution", "alias": "index_execution_active" }},
{ "add": { "index": "index_execution_20200414", "alias": "index_execution_active" }}
]
}
'