es修改mapping字段类型

说明:

es创建好映射后是不支持修改的,只能进行迁移到新的索引,然后设置别名(这样新建的那个索引就替代了原来的索引)

步骤:

1、 新建一个索引B
2、 把数据A的索引数据迁移到B(如果A数据一直在新增,他只能同步操作时刻总量)
3、 删除老索引A
4、 把新的索引B设置别名为A

实例:

详细步骤:

  1. 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"
      }
    }
  }
}
  1. 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"
  }
}
  1. 3、删除索引

    DELETE pre_log_archives
    
  2. 4、设置别名

    POST /_aliases
      {
            "actions": [
                {"add": {"index": "pre_log_archives2", "alias": "pre_log_archives"}}
            ]
      }
    
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值