Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
work_note
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
work_note
Commits
e47cc064
提交
e47cc064
authored
10月 10, 2023
作者:
陈世强
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upload New File
上级
2bbc747e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
945 行增加
和
0 行删除
+945
-0
ES修改数据类型测试.md
ES修改数据类型测试.md
+945
-0
没有找到文件。
ES修改数据类型测试.md
0 → 100644
浏览文件 @
e47cc064
#### 0.创建有数据的索引
#### 0.创建有数据的索引
##### 创建索引
```
PUT /basedatatest
{
"mappings" : {
"properties" : {
"attachmentIds" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"author" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"authorRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"batchNo" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"checkStatus" : {
"type" : "long"
},
"clbId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentHash" : {
"type" : "long"
},
"contentRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentSimilar" : {
"type" : "long"
},
"contentWithTag" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentWithTagRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"createDate" : {
"type" : "date"
},
"deleteFlag" : {
"type" : "long"
},
"downLoadUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"id" : {
"type" : "keyword"
},
"importance" : {
"type" : "long"
},
"infoSourceType" : {
"type" : "keyword"
},
"keyWords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword"
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"labels" : {
"type" : "nested",
"properties" : {
"hitRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelMark" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemaks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"projectLabelId;" : {
"type" : "keyword"
},
"relationId" : {
"type" : "keyword"
},
"relationName" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"status" : {
"type" : "integer"
}
}
},
"lang" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"langRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"origin" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originalDate" : {
"type" : "date"
},
"originalTime" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"publishDate" : {
"type" : "date"
},
"repeatId" : {
"type" : "long"
},
"screenShotImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"sid" : {
"type" : "keyword"
},
"similarTp" : {
"type" : "long"
},
"source" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"sourceAddress" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"subjectId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"summary" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"summaryRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"title" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleDistinctId" : {
"type" : "long"
},
"titleHash" : {
"type" : "long"
},
"titleRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleSimilar" : {
"type" : "long"
},
"topNum" : {
"type" : "long"
},
"type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"videoImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoPhoneUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoTime" : {
"type" : "long"
},
"videoUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
}
}
}
}
```
##### 添加数据
```
POST /basedatatest/_doc/1
{
"id": 1,
"sid": "1",
"title": "zzsn is a company",
"content": "I'm testing data moving for es"
}
```
#### 1. 创建一个中间索引
##### 创建Mapping
```
PUT /basedatatest_temp
{
"mappings" : {
"properties" : {
"attachmentIds" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"author" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"authorRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"batchNo" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"checkStatus" : {
"type" : "long"
},
"clbId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentHash" : {
"type" : "long"
},
"contentRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentSimilar" : {
"type" : "long"
},
"contentWithTag" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentWithTagRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"createDate" : {
"type" : "date"
},
"deleteFlag" : {
"type" : "long"
},
"downLoadUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"id" : {
"type" : "keyword"
},
"importance" : {
"type" : "long"
},
"infoSourceType" : {
"type" : "keyword"
},
"keyWords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword"
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"labels" : {
"type" : "nested",
"properties" : {
"hitRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelMark" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemaks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"projectLabelId;" : {
"type" : "keyword"
},
"relationId" : {
"type" : "keyword"
},
"relationName" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"status" : {
"type" : "integer"
}
}
},
"lang" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"langRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"origin" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originalDate" : {
"type" : "date"
},
"originalTime" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"publishDate" : {
"type" : "date"
},
"repeatId" : {
"type" : "long"
},
"screenShotImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"sid" : {
"type" : "keyword"
},
"similarTp" : {
"type" : "long"
},
"source" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"sourceAddress" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"subjectId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"summary" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"summaryRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"title" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleDistinctId" : {
"type" : "long"
},
"titleHash" : {
"type" : "long"
},
"titleRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleSimilar" : {
"type" : "long"
},
"topNum" : {
"type" : "long"
},
"type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"videoImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoPhoneUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoTime" : {
"type" : "long"
},
"videoUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
}
}
}
}
```
#### 2. 向中间索引备份源索引的数据
```
POST _reindex
{
"source": {
"index": "basedatatest"
},
"dest": {
"index": "basedatatest_temp"
}
}
```
#### 3.查询确认数据是否copy过去
```
GET /basedatatest/type/_search
GET /basedatatest_temp/type/_search
```
#### 4.删除有问题的索引
##### 删除有问题的索引
```
DELETE basedatatest
```
#### 5.重新创建同名的索引(★字段类型修改正确★)
##### 创建Mapping
```
PUT /basedatatest
{
"mappings" : {
"properties" : {
"attachmentIds" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"author" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"authorRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"batchNo" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"checkStatus" : {
"type" : "long"
},
"clbId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentHash" : {
"type" : "long"
},
"contentRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentSimilar" : {
"type" : "long"
},
"contentWithTag" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"contentWithTagRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"createDate" : {
"type" : "date"
},
"deleteFlag" : {
"type" : "long"
},
"downLoadUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"id" : {
"type" : "keyword"
},
"importance" : {
"type" : "long"
},
"infoSourceType" : {
"type" : "keyword"
},
"keyWords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword"
}
},
"analyzer" : "ik_max_word",
"search_analyzer" : "ik_smart"
},
"labels" : {
"type" : "nested",
"properties" : {
"hitRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelMark" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemaks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"labelRemarks" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"projectLabelId;" : {
"type" : "keyword"
},
"relationId" : {
"type" : "keyword"
},
"relationName" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"status" : {
"type" : "integer"
}
}
},
"lang" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"langRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"origin" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originRaw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"originalDate" : {
"type" : "date"
},
"originalTime" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"publishDate" : {
"type" : "date"
},
"repeatId" : {
"type" : "long"
},
"screenShotImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"sid" : {
"type" : "keyword"
},
"similarTp" : {
"type" : "long"
},
"source" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"sourceAddress" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"subjectId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"summary" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"summaryRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"title" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleDistinctId" : {
"type" : "long"
},
"titleHash" : {
"type" : "long"
},
"titleRaw" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"titleSimilar" : {
"type" : "long"
},
"topNum" : {
"type" : "long"
},
"type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_max_word"
},
"videoImg" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoPhoneUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"videoTime" : {
"type" : "long"
},
"videoUrl" : {
"type" : "text",
"analyzer" : "ik_max_word"
}
}
}
}
```
#### 6. 从中间索引还原到源索引的数据
```
POST _reindex
{
"source": {
"index": "basedatatest_temp"
},
"dest": {
"index": "basedatatest"
}
}
```
#### 7. 删除中间索引
```
DELETE basedatatest_temp
```
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论