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

Elasticsearch重建索引

Elasticsearch重建索引

概述

很多情况下,Elasticsearch是需要重建索引的. 比如主分片数量想修改,加了keyword类型等.

操作步骤
1.首先创建一个新索引,结构一致
PUT /myindex_new
{
  "settings": {
    "number_of_shards": 2
    , "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "name":{
        "type": "keyword"
      },
      "age":{
        "type": "long"
      }
    }
  }
}

2.数据迁移
POST /_reindex?wait_for_completion=false
{
  "source": {
    "index": "myindex"
  },
  "dest": {
    "index": "myindex_new"
  }
}

3.删除老索引
DELETE myindex

3.给新索引加别名
POST _aliases 
{
  "actions": [
    {
      "add": {
        "index": "myindex_new",
        "alias": "myindex"
      }
    }
  ]
}
效果


索引名称已经变成myindex_new,为了不影响程序使用,使用别名myindex


name字段改成keyword,已经支持折叠了(collapse)

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

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

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