栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Elasticsearch替换索引的映射

Elasticsearch替换索引的映射

现有这么一个索引es_test,要将age和sex的字段类型从long改为integer

PUT /es_test/_doc/1
{
  "name": "张三",
  "sex": 1,
  "age": 23,
  "address": "广州天河公园"
}

原es_test的映射如下图右侧所示;

第一步,创建一个新的索引,定义好所需映射

PUT /es_test_bak
{
  "mappings": {
      "properties": {
        "name": {"type": "keyword", "index": true, "store": true},
        "sex": {"type": "integer", "index": true, "store": true},
        "age": {"type": "integer", "index": true, "store": true},
        "address": {"type": "text", "index":true, "store": true}
      }  
  }
}

第二步,将es_test索引的数据复制到es_test_bak索引里

POST _reindex
{
  "source": {
    "index": "es_test"
  },
  "dest": {
    "index": "es_test_bak"
  }
}

第三步,删除掉原es_test索引

DELETE /es_test

第四步,给es_test_bak索引设置一个es_test的别名

PUT /es_test_bak/_alias/es_test

第五步,确认

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/728876.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号