es修改mapping字段类型
说明:es创建好映射后是不支持修改的,只能进行迁移到新的索引,然后设置别名(这样新建的那个索引就替代了原来的索引)步骤:1、新建一个索引B2、把数据A的索引数据迁移到B(如果A数据一直在新增,他只能同步操作时刻总量)3、删除老索引A4、把新的索引B设置别名为A实例:详细步骤:1新建索引#新建PUT /pre_log_archives2{"mappings": {"properties": {"ac
·
说明:
es创建好映射后是不支持修改的,只能进行迁移到新的索引,然后设置别名(这样新建的那个索引就替代了原来的索引)
步骤:
1、 新建一个索引B
2、 把数据A的索引数据迁移到B(如果A数据一直在新增,他只能同步操作时刻总量)
3、 删除老索引A
4、 把新的索引B设置别名为A
实例:
详细步骤:
- 1新建索引
#新建
PUT /pre_log_archives2
{
"mappings": {
"properties": {
"acceptor": {
"type": "keyword"
},
"batchName": {
"type": "keyword"
},
"belongArea": {
"type": "keyword"
},
"belongDept": {
"type": "keyword"
},
"documentNumber": {
"type": "keyword"
},
"logSource": {
"type": "integer"
},
"operateResult": {
"type": "keyword"
},
"operateStatus": {
"type": "integer"
},
"operateTime": {
"type": "date"
},
"operateType": {
"type": "keyword"
},
"projId": {
"type": "keyword"
},
"remoteIP": {
"type": "keyword"
},
"requestJson": {
"type": "keyword"
},
"systemId": {
"type": "keyword"
},
"systemName": {
"type": "keyword"
},
"unid": {
"type": "long"
},
"userName": {
"type": "keyword"
},
"version": {
"type": "integer"
},
"withdrawNode": {
"type": "keyword"
}
}
}
}
- 2、同步数据迁移
(数据多会报超时,但是任务其实还在继续,不用管,任务详情查看http://IP:9200/_tasks?detailed=true&actions=*reindex)
POST _reindex
{
"source": {
"index": "pre_log_archives",
"size": 5000
},
"dest": {
"index": "pre_log_archives2",
"routing": "=cat"
}
}
-
3、删除索引
DELETE pre_log_archives
-
4、设置别名
POST /_aliases { "actions": [ {"add": {"index": "pre_log_archives2", "alias": "pre_log_archives"}} ] }
更多推荐
已为社区贡献6条内容
所有评论(0)