当前位置:网站首页>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());
边栏推荐
猜你喜欢
[Unity entry plan] Unity instance - how to protect data members through encapsulation in C#
leetcode 31. 下一个排列(实现next_permutation 函数)
干货:从零设计高并发架构
ASP.NET Core依赖注入之旅:4.体验服务的注册和消费
LED显示屏在会议室如何应用
[Online interviewer] How to achieve deduplication and idempotency
腾讯云产品可观测最佳实践 (Function)
api的封装
3 个开源项目,让你感受程序员的浪漫!
使用 FasterTransformer 和 Triton 推理服务器加速大型 Transformer 模型的推理
随机推荐
mmdetection最新版食用教程(一):安装并运行demo及开始训练coco
Web3构架是怎么样的?
[Unity Starter Plan] Making RubyAdventure02 - Handling Tile Maps & Collision
ImportError: numpy.core.multiarray failed to import [cv2, matplotlib, PyTorch, pyinstaller ]
3dsmax2021软件安装教程
Patience sorting - specializing in quickly solving the longest increasing subarray
找工作的我看了国聘app
9. cuBLAS Development Guide Chinese Version--Configuration of Atomic Mode in cuBLAS
Jingdong T9 pure hand type 688 pages of god notes, SSM framework integrates Redis to build efficient Internet applications
ctfshow七夕杯复现
spark集群环境搭建
IDEA2020安装教程
C#/VB.NET 将PDF转为PDF/X-1a:2001
【软件工程之美 - 专栏笔记】40 | 最佳实践:小团队如何应用软件工程?
redis的详细介绍与操作命令
Lecture 207, Class Schedule
bzoj2816 [ZJOI2012] Network
NSSCTF部分复现
ESP8266-Arduino编程实例-ADXL345三轴加速计驱动
手机注册股票开户的流程?网上开户安全?