Elasticsearch修改字段类型 (_reindex)
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)的更多相关文章
- sqlServer 2008修改字段类型和重命名字段名称的sql语句
sqlServer 2008修改字段类型和重命名字段名称的sql语句 //修改字段的类型 alter table fdi_news alter column c_author nvarchar(50) ...
- Oracle/SQL 修改字段类型和长度
标准SQL修改字段类型和长度语句: ALTER TABLE tableName modify column columnName 类型;例如Mysql的修改字段类型语句:alter table tes ...
- Mysql字段操作—增加字段、删除字段、修改字段名、修改字段类型(约束条件)
1.增加字段: alter table tablename add new_field_id type not null default '0'; 例: a ...
- oracle如何修改字段类型(oracle总体知识2)
在一次做开发的时候,遇到需要将数据表的字段类型由number改成varchar,可是该字段又有值, 用 alter table t-name modify cname newType;会报错. 话说 ...
- Oracle修改字段类型和长度
Oracle修改字段名 alter table 表名 rename column 旧字段名 to 新字段名 Oracle修改字段类型和长度 alter table 表名 modify 字段名 数据类型 ...
- sql语句修改字段类型和增加字段
/*修改字段类型*/ ) go /*增加字段和说明*/ ) EXECUTE sp_addextendedproperty N'MS_Description','说明文字',N'user',N'dbo' ...
- Oracle创建表、修改字段类型
1.创建表 1.创建表 create table SCM_PER( --SCM_PER表名 ID ) primary key,--主键ID USERID ),--用户ID --Permission v ...
- Oracle基本操作,Oracle修改列名,Oracle修改字段类型
oracle基本操作,Oracle修改列名,Oracle修改字段类型 >>>>>>>>>>>>>>>>& ...
- 曲演杂坛--使用ALTER TABLE修改字段类型的吐血教训
--===================================================================== 事件起因:开发发现有表插入数据失败,查看后发现INT类型 ...
随机推荐
- IDEA编写JavaWeb出现乱码,成功解决!
使用IDEA写JavaWeb项目时,总会出现编码出错等问题,比如下面这样,页面显示出来一大堆乱码,下面跟着我来操作一下,可以成功解决! 首先在IDEA安装目录下有一个:bin的文件夹,打开后找到如下两 ...
- jenkins打包java maven项目
一.maven本地配置 1.修改apache-maven-3.6.1\conf\settings.xml文件,把仓库配置成本地仓库 <localRepository>D:\apache-m ...
- Appium之定位元素
常用的appium元素定位工具: (1)Android SDK 中提供的元素定位工具uiautomatorviewer: (2)AppiumDesktop提供的元素定位工具Appium Inspec ...
- Django+pycharm+mysql 实现用户登录/注册(Django五)
首先是让Django项目与mysql数据库初步建立连接 具体做法见:pycharm连接mysql(注意其中第二步MySQL驱动最好安装最新版的) 这里讲一下我在做这一步遇到的问题.一般Driver 那 ...
- C语言01
从问题到C语言程序设计 1.1计算机的问题求解方法 程序设计面向的问题 什么问题可以用程序的方法解决? 打印九九乘法表 图形变换 文件压缩问题 ....... 一切可计算的问题 如何解决? 确定问题可 ...
- SM4密码算法matlab实现
%function C=SM4(X,K,M)%M为1时进行加密,M为0时进行解密操作,X为明文/密文输入,K为密钥输入X='0123456789abcdeffedcba9876543210';%X=' ...
- dubbo负载均衡
dubbo 一.同一个dubbo生产者服务怎么分布在不同服务器,且能进行负载均衡? 只要两个服务的id,接口,实现类一致(且dubbo:application名称一致,表示同一应用),注册到同一zoo ...
- Mybatis快速逆向生成代码
先下载生成器的文件, 并在eclipse或者IDEA里面打开这个工程 热乎乎的链接 然后配置一下 选择你需要生成的数据的ip和端口 点击运行入口函数 运行成功 接着在浏览器输入localhost: 这 ...
- 9.Kafka API使用
- Win10使用VMWare15安装Ubuntu-18.04.2-desktop-amd64
本文在Win10系统中使用VMWare Workstation Pro 15.1.0虚拟机安装Ubuntu-18.04.2-desktop-amd64.iso系统,同时安装VMWare Tools(实 ...