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类型 ...
随机推荐
- 嵌入式Linux软链接使用技巧
软链接概述 软链接是Linux下常用的一种共享文件方式.目录的方式,这种方式类似于Windows下的快捷方式.一般一个文件或者目录在不同的路径都需要的时候,可以通过创建软链接的方式来共享,这样只系统下 ...
- 备忘录:SQL SERVER2014 出现:“Cannot find one or more components”
目录 1. 起因 2. 解决方案 3. 备注 4. 参考 2020年9月13日 00:40:09-shanzm 1. 起因 因为卸载vs2015的时候,使用了一个VS2013/2015卸载工具Tota ...
- xss原理解析
xss->跨站脚本攻击 xss是指攻击者在网页中嵌入客户端脚本.通常是指javascript编写的一个危险代码,当用户使用浏览器浏览网页时,脚本就会在用户的浏览器上执行,从而达到攻击者的目的. ...
- 对OAuth2.0协议的理解和测试demo
1. 什么是OAuth OAuth(开放授权)是一个开放标准,允许用户授权第三方网站访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方网站或分享他们数据的所有内容. OAuth ...
- v-charts 绘制柱状图、条形图、水球图、雷达图、折线图+柱状图,附官网地址
v-charts 官网地址:https://v-charts.js.org/#/ 柱状图: <template> <ve-histogram :data="chartDat ...
- 通过adrci ips打包incident给oracle
1.adrci查看incident 2.show home 3.set home adrci> set home diag/rdbms/mesdb/mesdb1 4.show incident ...
- 【大数据】MapReduce开发小实战
Before:前提:hadoop集群应部署完毕. 一.实战科目:做一个Map Reduce分布式开发,开发内容为统计文件中的单词出现次数. 二.战前准备 1.本人在本地创建了一个用于执行MR的的文件, ...
- 基本的PID算法整理(水缸的例子有问题!!)
一,先谈关于水缸漏水的问题 谈到PID原理入门的时候,大家经常会举的一个例子就是水缸漏水的例子.这里把一个解释水缸漏水的帖子放在这里:https://blog.csdn.net/qq_41736609 ...
- FTP服务器稳定性测试
FTP服务器稳定性探讨,如何部署FTP服务在server2003上,可能广大网友们有其他的选择,我选择的是Filezilla server.毕竟他是开源又免费 在架构师的悉心指导下,对FTP有了个更深 ...
- 从 LRU Cache 带你看面试的本质
前言 大家好,这里是<齐姐聊算法>系列之 LRU 问题. 在讲这道题之前,我想先聊聊「技术面试究竟是在考什么」这个问题. 技术面试究竟在考什么 在人人都知道刷题的今天,面试官也都知道大家会 ...