elasticsearch不支持直接修改字段类型,解决思路:
新建临时索引,执行字段类型,复制数据
删除旧索引,重建同名索引,从临时索引复制数据
#获取旧索引的字段映射
GET /users/_mapping
#创建临时索引带映射
PUT /users_temp { "mappings": { "user": { "properties": { "age": { "type": "long" }, } } } }
#复制数据
POST /_reindex { "source": { "index": "users" }, "dest": { "index": "users_temp" } }
#删除旧索引
DELETE /users
#创建新索引带映射
PUT /users { "mappings": { "user": { "properties": { "age": { "type": "long" }, } } } }
#复制数据
POST /_reindex { "source": { "index": "users_temp", "query": { "match_all": {} } }, "dest": { "index": "users" } }
#删除临时索引
DELETE /users_temp
无论从事什么行业,只要做好两件事就够了,一个是你的专业、一个是你的人品,专业决定了你的存在,人品决定了你的人脉,剩下的就是坚持,用善良專業和真诚赢取更多的信任。