当前位置:网站首页>Es的索引操作(代码中的基本操作)
Es的索引操作(代码中的基本操作)
2022-08-08 16:26:00 【永远的HelloWorld】
// 1.创建客户端对象 RestHighLevelClient client = new RestHighLevelClient( RestClient.builder(new HttpHost("localhost", 9200, "http")) );
(1)创建索引
// 创建索引 - 请求对象 CreateIndexRequest request = new CreateIndexRequest("user");
// 发送请求,获取响应 CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); boolean acknowledged = response.isAcknowledged();
// 响应状态 System.out.println("操作状态 = " + acknowledged);
(2)查看索引
// 查询索引 - 请求对象 GetIndexRequest request = new GetIndexRequest("user"); // 发送请求,获取响应 GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT); System.out.println("aliases:"+response.getAliases()); System.out.println("mappings:"+response.getMappings()); System.out.println("settings:"+response.getSettings());
(3)删除索引
// 删除索引 - 请求对象 DeleteIndexRequest request = new DeleteIndexRequest("user");
// 发送请求,获取响应 AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);
// 操作结果 System.out.println("操作结果 : " + response.isAcknowledged());
边栏推荐
猜你喜欢
随机推荐
leetcode 31. 下一个排列(实现next_permutation 函数)
NSSCTF部分复现
我分析30w条数据后发现,西安新房公摊最低的竟是这里?
华为云分布式缓存服务Redis开通及使用规划教程【华为云至简致远】
本博客目录及版权申明
[Unity entry plan] Use the double blood bar method to control the blood loss speed of the damage area
mmdetection最新版食用教程(一):安装并运行demo及开始训练coco
耐心排序——专门快速解决最长递增子数组
web automation headless mode
bzoj1269 [AHOI2006]文本编辑器editor
3dsmax2021软件安装教程
调研阶段复盘
带你玩转“超大杯”ECS特性及实验踩坑【华为云至简致远】
leetcode 155. Min Stack最小栈(中等)
GHOST tool to access the database
Thread local storage ThreadLocal
赶紧进来修内功!!!带你认识C语言中各种进制数和原码反码补码.
redis的详细介绍与操作命令
广东大学生网络安全攻防大赛CTF部分WP
The origin and creation of Smobiler's complex controls