1.设置索引t2为想要的数据类型

2.将t1 reindex到t2

3.数据reindex完成删除t1

4.设置索引t1为想要的数据类型

5.将t2 reindex到t1

如果 _reindex 超时 返回504等

通过语句可以看到任务还在进行, 数据还在迁移中
GET _tasks?actions=*reindex&detailed
PUT t1
{
"settings": {
"index": {
"number_of_shards": "2",
"analysis": {
"analyzer": {
"ik_custom_analyzer": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "ik_max_word"
}
}
},
"number_of_replicas": "1"
}
},
"mappings": {
"doc": {
"properties": {
"abs_path": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"comp_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id_path": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"index_update_time": {
"type": "long"
},
"name": {
"type": "text",
"analyzer": "ik_custom_analyzer"
},
"parent_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"star": {
"type": "long"
},
"time": {
"type": "long"
},
"weight": {
"type": "long"
}
}
}
}
} PUT /t2
{ "settings": {
"number_of_shards": 2,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"simplechar_index_analyzer": {
"type": "custom",
"tokenizer": "simplechar_index"
},
"simplechar_search_analyzer": {
"type": "custom",
"tokenizer": "simplechar_search"
},
"pinyin_index_analyzer": {
"type": "custom",
"tokenizer": "pinyin_index"
},
"pinyin_search_analyzer": {
"type": "custom",
"tokenizer": "pinyin_search"
}
},
"tokenizer": {
"simplechar_index": {
"type": "simplechar_and_pinyin",
"simple_char": true,
"prefix_en": true,
"prefix_num": true
},
"simplechar_search": {
"type": "simplechar_and_pinyin",
"simple_char": true,
"prefix_num": true,
"prefix_en": true
},
"pinyin_index": {
"type": "simplechar_and_pinyin",
"simple_char": true,
"han_to_pinyin": true,
"keep_first": true,
"keep_fuzzy": true,
"simple_num": true
},
"pinyin_search": {
"type": "simplechar_and_pinyin",
"simple_char": true,
"en_to_pinyin": true,
"simple_num": true
}
}
}
},
"mappings": {
"doc": {
"properties": {
"name": {
"type": "text",
"analyzer": "simplechar_index_analyzer",
"search_analyzer": "simplechar_search_analyzer",
"similarity": "boolean",
"fielddata": true,
"fields": {
"pinyin": {
"type": "text",
"similarity": "boolean",
"analyzer": "pinyin_index_analyzer",
"search_analyzer": "pinyin_search_analyzer",
"fielddata": true
}
}
}
}
}
}
} PUT t1/doc/3
{
"id": "3",
"name": "第七层",
"star": 0,
"parent_id": "134111385604698112",
"comp_id": "500000151",
"abs_path": "啤啤第三个公司/这个是子部门1/这个是部门下的部门/再加/第五层/第六层/第七层",
"id_path": "131773053453164544,131775211384823808,131775319170052096,132666474766233600,134111338699763712,134111385604698112,134112080391122944",
"weight": "2",
"index_update_time": 1547469387,
"time": 1547469386994201600
} GET t1/doc/_search
{
"size": 20,
"query": {
"match_all": {}
}
} POST _reindex
{
"source": {
"index": "t1"
},
"dest": {
"index": "t2",
"version_type": "external"
},
"script": {
"source":"def w = ctx._source.remove('weight');ctx._source.weight=w;",
"lang": "painless"
}
}
GET t1/_mapping
GET t2/_mapping GET t2/doc/_search
{
"size": 20,
"query": {
"match_all": {}
}
}

Elasticsearch修改字段类型 (_reindex)的更多相关文章

  1. sqlServer 2008修改字段类型和重命名字段名称的sql语句

    sqlServer 2008修改字段类型和重命名字段名称的sql语句 //修改字段的类型 alter table fdi_news alter column c_author nvarchar(50) ...

  2. Oracle/SQL 修改字段类型和长度

    标准SQL修改字段类型和长度语句: ALTER TABLE tableName modify column columnName 类型;例如Mysql的修改字段类型语句:alter table tes ...

  3. Mysql字段操作—增加字段、删除字段、修改字段名、修改字段类型(约束条件)

    1.增加字段:    alter table   tablename    add   new_field_id   type   not null default '0';     例:     a ...

  4. oracle如何修改字段类型(oracle总体知识2)

    在一次做开发的时候,遇到需要将数据表的字段类型由number改成varchar,可是该字段又有值, 用  alter table t-name modify cname newType;会报错. 话说 ...

  5. Oracle修改字段类型和长度

    Oracle修改字段名 alter table 表名 rename column 旧字段名 to 新字段名 Oracle修改字段类型和长度 alter table 表名 modify 字段名 数据类型 ...

  6. sql语句修改字段类型和增加字段

    /*修改字段类型*/ ) go /*增加字段和说明*/ ) EXECUTE sp_addextendedproperty N'MS_Description','说明文字',N'user',N'dbo' ...

  7. Oracle创建表、修改字段类型

    1.创建表 1.创建表 create table SCM_PER( --SCM_PER表名 ID ) primary key,--主键ID USERID ),--用户ID --Permission v ...

  8. Oracle基本操作,Oracle修改列名,Oracle修改字段类型

    oracle基本操作,Oracle修改列名,Oracle修改字段类型 >>>>>>>>>>>>>>>>& ...

  9. 曲演杂坛--使用ALTER TABLE修改字段类型的吐血教训

    --===================================================================== 事件起因:开发发现有表插入数据失败,查看后发现INT类型 ...

随机推荐

  1. pwnable.kr之bof

    打开题目: 先下载题目给我们的两个文件,查看文件信息: 发现没有执行的权限,所以先增加文件bof的执行权限,执行: 没发现啥,然后查看代码, #include <stdio.h> #inc ...

  2. ASP.NET Core 性能优化最佳实践

    本文提供了 ASP.NET Core 的性能最佳实践指南. 译文原文地址:https://docs.microsoft.com/en-us/aspnet/core/performance/perfor ...

  3. PHP开发规范1.3.3

    PHP 开发规范1.3.3 一.编程规约 (一) 命名风格 [强制]代码中的命名严禁使用拼音与英文混合的方式,更不允许直接使用中文的方式. 说明: 正确的英文拼写和语法可以让阅读者易于理解,避免歧义. ...

  4. 利用 QEMU USER 模式运行 mips 程序

    摘要 关键字: qemu mips 前述 QEMU是一个处理器模拟软件,可以用来在PC中模拟ARM.MIPS等多种架构的软硬件运行环境.QEMU主要有两种模拟模式: User Mode System模 ...

  5. 软件工程与UML作业3(互评作业)

    博客班级 https://edu.cnblogs.com/campus/fzzcxy/2018SE1/ 作业要求 https://edu.cnblogs.com/campus/fzzcxy/2018S ...

  6. 处理IOS浏览器在input或者textarea获取焦点后底部留一块灰色空白区域的bug

    document.body.addEventListener('focusout',function() { window.scrollTo(0,0) },false);

  7. tomact在windows系统下安装

    一.下载 下载地址: https://tomcat.apache.org/download-90.cgi 7,8,9的版本都可以下,这里下载最新版本 注意:Binary是编译好的,可以直接使用的版本, ...

  8. 为什么阿里巴巴禁止使用BigDecimal的equals方法做等值比较?

    GitHub 17k Star 的Java工程师成神之路,不来了解一下吗! GitHub 17k Star 的Java工程师成神之路,真的不来了解一下吗! GitHub 17k Star 的Java工 ...

  9. Redis5设计与源码分析读后感(二)简单动态字符串SDS

    一.引言 学习之前先了解几个概念: SDS定义:简单动态字符串,Redis的基本数据结构之一,用于储存字符串和整型数据. 二进制安全:C语言中用"\0"表示字符串结束,如果字符串本 ...

  10. document对象-操作元素的文档结构

    1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="U ...