当前位置: 首页 > news >正文

SpringBoot ES 重建 Mapping

SpringBoot ES 重建 Mapping

  • 1 复制数据
  • 2 删除老索引
  • 3 重建索引
  • 4 复制回数据

1 复制数据

POST http://elastic:123456@127.0.0.1:9200/_reindex
{"source": {"index": "老索引名称"},"dest": {"index": "备份索引名称"}
}

2 删除老索引

DELETE http://elastic:123456@127.0.0.1:9200//aicc_spp_audio_800808618

3 重建索引

package org.jeecg.modules.mark.common.es.setting;import lombok.Data;/*** ElasticSearch 索引设置** @date 2023年12月21日09点47分* @since V1.0.0.0*/
@Data
public class ElasticSearchSetting {/*** 是指索引要做多少个分片,只能在创建索引时指定,后期无法修改。*/private int number_of_shards = 3;/*** 每个分片有多少个副本,后期可以动态修改。*/private int number_of_replicas = 1;/*** max_result_window 是分页返回的最大数值,默认值为10000。*/private int max_result_window = 20000000;}
@Test
void createIndex() {String indexName = "索引名称";IndexCoordinates index = IndexCoordinates.of(indexName);if (!restTemplate.indexOps(index).exists()) {final Document mapping = restTemplate.indexOps(index).createMapping(AudioMarkInfo.class);mapping.put("date_detection", false);mapping.put("numeric_detection", false);final Document parse = Document.parse(JSONUtil.toJsonStr(new ElasticSearchSetting()));restTemplate.indexOps(index).create(parse);restTemplate.indexOps(index).putMapping(mapping);log.info("ES索引{}不存在,创建ES索引完成!", index.getIndexName());}
}

4 复制回数据

POST http://elastic:123456@127.0.0.1:9200/_reindex
{"source": {"index": "备份索引名称"},"dest": {"index": "新索引名称"}
}
http://www.lryc.cn/news/285026.html

相关文章:

  • 【51单片机】矩阵按键
  • Redis- AOF刷盘策略
  • 标量、向量、矩阵和张量的区别?
  • 【51单片机】动态数码管
  • Webpack5入门到原理22:提升打包构建速度
  • EXCEL VBA获取幸运数字号码
  • 【标准IO】fseek函数、ftell函数、fflush函数、getline函数
  • VSCODE使用CMAKE显示命令无法找到
  • 【SpringCloud】微服务框架后端部署详细过程记录20240119
  • 《设计模式的艺术》笔记 - 桥接模式
  • Redis高并发分布式锁
  • 组件开发遇到的问题(vue的问题)
  • vue3前端开发,感受一下组合式api和VUE2选项式的差异
  • 电梯调度问题文献阅读
  • 文心一言 VS 讯飞星火 VS chatgpt (183)-- 算法导论13.4 7题
  • ChatGLM vs ChatGPT
  • leetcode热题100.三数之和
  • GitLab服务器忘记root密码处理方式
  • js-cookie的使用--token的数据实现持久化
  • 【实战】SpringBoot自定义 starter及使用
  • 网络爬虫采集工具
  • 【协议】XMLHttpRequest的梳理和总结
  • AI教我学编程之C#类的基本概念(1)
  • 前端js 数据结构:对象 object、数组Array 、Map 的创建、增删改 / 遍历数据
  • ARM_Linux的NFS网络文件系统的搭建
  • vscode配置web开发环境(WampServer)
  • 00-Rust前言
  • 3.conda的使用
  • IPv6自动隧道---6to4中继
  • 低代码开发:解锁数字化转型新维度