一、概述
首先说明es中索引的字段类型是不可修改的,只能是重新创建一个索引并设置好映射mapping,然后再将老索引的数据复制过去。
二、原索引字段text类型
三、操作步骤
-
创建索引,并指定映射mapping
PUT /audit2 { "mappings": { "properties": { "@timestamp": { "type": "date" }, "@version": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "childmodule": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "dmltype": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "id": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "masterid": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "module": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "objectchangedata": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "objectid": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "objectkey": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "operationdetail": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "operationtime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }, "operatoremployeeno": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "operatorpersonname": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "product": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "tenant": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "type": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } } }
2、将老的索引中的数据复制到新的索引中:
POST _reindex { "source": { "index": "audit-q-2021-11" }, "dest": { "index": "audit2" } }
3、显示audit2索引已有同步过来的数据(时间字段由原来的text变为了date类型)
热门文章
- 「12月22日」最高速度20.2M/S,2024年WinXray每天更新免费节点订阅链接
- 合肥宠物救助站电话(合肥宠物救助领养中心)
- 「12月9日」最高速度18.4M/S,2024年WinXray每天更新免费节点订阅链接
- 这几种方法帮你快速实现回到页面顶部
- 「11月30日」最高速度22.5M/S,2024年WinXray每天更新免费节点订阅链接
- Parquet文件是怎么被写入的-Row Groups,Pages,需要的内存,以及flush操作
- 「1月28日」最高速度18.5M/S,2025年WinXray每天更新免费节点订阅链接
- kafka3.0.0启动异常
- 「12月4日」最高速度18.2M/S,2024年WinXray每天更新免费节点订阅链接
- 「1月18日」最高速度21.4M/S,2025年WinXray每天更新免费节点订阅链接