网站打开显示站点目录/百度网页推广怎么做
一 SpringBoot + Elasticsearch 项目环境搭建
1.1 修改pom文件添加依赖
目前使用spring-boot-starter-parent版本为2.2.8.RELEASE
对应spring-data-elasticsearch版本为2.2.8.RELEASE,版本对应可以自行百度,如果不行直接用elasticsearch-rest-high-level-client工具类吧
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId><version>2.2.8.RELEASE</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>7.5.0</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId><version>7.5.0</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>7.5.0</version></dependency>
1.2 新建配置文件
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** ES配置类** @author lc* @version 1.0* @date 2022/3/25 10:53*/
@Configuration
public class ElasticSearchClientConfig {@Beanpublic RestHighLevelClient restHighLevelClient() {RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost("192.168.1.100", 9200, "http")));return client;}
}
二 RestHighLevelClient的使用
RestHighLevelClient是Elasticsearch 的操作方法,我们先进行引用吧。
@Autowired
private RestHighLevelClient client;
1、创建索引
@Testvoid testCreateIndex() throws IOException {//1 创建索引请求CreateIndexRequest request = new CreateIndexRequest("zlc_index");//2 客户端执行请求CreateIndexResponse createIndexResponse =client.indices().create(request, RequestOptions.DEFAULT);System.out.println(createIndexResponse);}
2、索引是否存在
@Testvoid testExistIndex() throws IOException {GetIndexRequest request = new GetIndexRequest("zlc_index");boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);System.out.println(exists);}
3、删除索引
@Testvoid testDeleteIndex() throws IOException {DeleteIndexRequest request = new DeleteIndexRequest("zlc_index");AcknowledgedResponse delete = client.indices().delete(request, RequestOptions.DEFAULT);System.out.println(delete.isAcknowledged());}
4、添加文档
@Testvoid testAddDocument() throws IOException {//创建对象UserES user = new UserES();user.setUserName("suwerw");user.setUserPhone("178245774");//创建请求IndexRequest request = new IndexRequest("zlc_index");//规则 put /zlc_index/_doc/1request.id("1");request.timeout(TimeValue.timeValueSeconds(1));request.timeout("1s");//将数据放入请求request.source(JSON.toJSONString(user), XContentType.JSON);//客户端发送请求,获取响应结果IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);System.out.println(indexResponse.toString());System.out.println(indexResponse.status());}
5、判断文档是否存在
@Testvoid testIsExists() throws IOException {GetRequest getRequest = new GetRequest("zlc_index", "1");//不获取返回的 _source 的上下文,提高效率getRequest.fetchSourceContext(new FetchSourceContext(false));getRequest.storedFields("_none_");boolean exists = client.exists(getRequest, RequestOptions.DEFAULT);System.out.println(exists);}
6、获取文档
@Testvoid testGetDocument() throws IOException {GetRequest getRequest = new GetRequest("zlc_index", "1");GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);System.out.println(getResponse);System.out.println(getResponse.getSourceAsString());}
7、更新文档信息
@Testvoid testUpdateDocument() throws IOException {UpdateRequest updateRequest = new UpdateRequest("zlc_index", "1");updateRequest.timeout("1s");UserES user = new UserES();user.setUserName("Zhou_LC");user.setUserPhone("233669");updateRequest.doc(JSON.toJSONString(user), XContentType.JSON);UpdateResponse updateResponse = client.update(updateRequest, RequestOptions.DEFAULT);System.out.println(updateResponse);System.out.println(updateResponse.status());}
8、删除文档
@Testvoid testDeleteDocument() throws IOException {DeleteRequest deleteRequest = new DeleteRequest("zlc_index", "1");deleteRequest.timeout("1s");DeleteResponse deleteResponse = client.delete(deleteRequest, RequestOptions.DEFAULT);System.out.println(deleteResponse);System.out.println(deleteResponse.status());}
相关文章:

使用springboot对Elasticsearch 进行索引的增、删、改、查
一 SpringBoot Elasticsearch 项目环境搭建 1.1 修改pom文件添加依赖 目前使用spring-boot-starter-parent版本为2.2.8.RELEASE 对应spring-data-elasticsearch版本为2.2.8.RELEASE,版本对应可以自行百度,如果不行直接用elasticsearch-rest-high-lev…...

Project#2: Extendible Hash Index
文章目录 准备Task #1-Read/Write Page GuardsBasicPageGuard/ReadPageGuard/WritePageGuardUpgradeWrappersTests Task #2-Extendible Hash Table PagesHash Table Header Pages**成员变量:****方法实现:** Hash Table Directory Pages**成员变量&#…...

Emscripten + CMakeLists.txt 将 C++ 项目编译成 WebAssembly(.wasm)/js,并编译 Html 测试
背景:Web 端需要使用已有的 C 库(使用 CMake 编译),需要将 C 项目编译成 WebAssembly(.wasm) 供 js 调用。 上篇文章《Mac 上安装 Emscripten》 已讲解如何安装配置 Emscripten 环境。 本篇文章主要讲解如何将基于 CMakeLists 配…...

MATLAB中preparets函数用法
目录 语法 说明 示例 准备开环和闭环网络的数据 preparets函数的功能是为网络模拟或训练准备输入和目标时间序列数据 语法 [Xs,Xi,Ai,Ts,EWs,shift] preparets(net,Xnf,Tnf,Tf,EW) 说明 [Xs, Xi, Ai, Ts, EWs, shift] preparets(net, Xnf, Tnf, Tf, EW) 这个函数接受…...

ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南续篇
作者:运维有术 前言 知识点 定级:入门级KubeKey 安装部署 ARM 版 KubeSphere 和 KubernetesARM 版 KubeSphere 和 Kubernetes 常见问题 实战服务器配置 (个人云上测试服务器) 主机名IPCPU内存系统盘数据盘用途ks-master-1172.16.33.1661650200KubeSp…...

react官网
应急方案 – React 中文文档 (docschina.org) 正版卡死版 Hooks FAQ – React (reactjs.org) 英文流畅版 应急方案 – React 中文网 (nodejs.cn) 盗版流畅版(翻译有稍稍的问题) http://www.react-cn.com/index.html 黄版...

前端css介绍
CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素。 当浏览器读到一个样式表,它就会按照这个样式表来对文档进行格式化(渲染)。 CSS语法 CSS实例 每个CSS样式由两个组成部分:选择器和…...

MySql创建索引
在MySQL中,可以使用CREATE INDEX语句来创建索引。以下是创建索引的基本语法: CREATE INDEX index_name ON table_name (column1, column2, ...);其中,index_name是索引的名称,可以自定义(也可以不指定索引名称&#x…...

前后端分离vue+springboot家庭理财账单财务管理系统
项目介绍: 该系统能够管理家庭收入支出,并且能直观得表现收支状态。主要功能包括用户管理、收支管理、财务管理、统计收支情况等功能。 技术栈: 后端: SpringBoot,Sa-Token,MyBatis-Plus,MyB…...

LeetCode:2003. 每棵子树内缺失的最小基因值(C++)
目录 2003. 每棵子树内缺失的最小基因值 题目描述: 实现代码与解析: dfs 启发式合并 原理思路: 2003. 每棵子树内缺失的最小基因值 题目描述: 有一棵根节点为 0 的 家族树 ,总共包含 n 个节点,节点编…...

React Hooks之useContext使用
官方文档写道:在组件的顶层调用 useContext 来读取和订阅 context。 我理解就是一个“全局变量”的概念。它可以用来声明一个变量,然后在各个组件中使用,避免了props一级一级往下传,当然使用场景有限,比如设置一个主题…...

多模态对比语言图像预训练CLIP:打破语言与视觉的界限
项目设计集合(人工智能方向):助力新人快速实战掌握技能、自主完成项目设计升级,提升自身的硬实力(不仅限NLP、知识图谱、计算机视觉等领域):汇总有意义的项目设计集合,助力新人快速实…...

使用s3cmd访问S3存储 -【真实案例】
背景 项目中使用到了 S3 存储(基于华为云 OBS),并且在应用服务器上开通了到 S3 存储的防火墙。 👉 目标:在应用服务器上验证 S3 存储是否通畅可用。 👉 选型:经过分析,发现在 Linux 下可以使用 s3cmd 来访问 S3 存储。 s3cmd 简介 s3cmd 是一个开源免费的、基于 P…...

51单片机复位电容计算与分析(附带Proteus电路图)
因为iC x (dU/dt).在上电瞬间,U从0变化到U,所以这一瞬间就是通的,然后这就是一个直流回路,因为电容C直流中是断路的,所以就不通了。 然后来分析一下这个电容的电压到底是能不能达到单片机需要的复位电压。 这是一个线性电容&…...

前端性能瓶颈崩溃项目?Webpack助力解决!
🎬 江城开朗的豌豆:个人主页 🔥 个人专栏 :《 VUE 》 《 javaScript 》 📝 个人网站 :《 江城开朗的豌豆🫛 》 ⛺️ 生活的理想,就是为了理想的生活 ! 目录 ⭐ 专栏简介 📘 文章引言 一、背…...

纷享销客BI,助力企业激活数据价值,科学企业决策
10月25日上午,国家数据局正式挂牌成立,这标志着我国数字经济发展将进入新的发展阶段,也将有力促进数据要素技术创新、开发利用和有效治理,以数据强国支撑数字中国的建设。伴随数据作为企业新的生产要素的意义不断凸显,…...

SpringBoot整合阿里云OSS对象存储
文章目录 1、OSS介绍及开通1.1、阿里云OSS简介1.2、开通OSS 2、创建存储空间bucket及密钥获取2.1、创建存储空间2.2、获取密钥 3、OSS快速入门案例4、在springboot项目中整合4.1、将oss配置放到yml文件中4.2、创建Oss属性类,接收yml文件中的属性4.3、封装文件上传功…...

【ES专题】ElasticSearch快速入门
目录 前言从一个【搜索】说起 阅读对象阅读导航笔记正文一、全文检索1.1 什么是【全文检索】1.2 【全文检索】原理1.3 什么是倒排索引 二、ElasticSearch简介2.1 ElasticSearch介绍2.2 ElasticSearch应用场景2.3 数据库横向对比 三、ElasticSearch环境搭建3.1 Windows下安装3.2…...

案例分析真题-质量属性
案例分析真题-质量属性 2009 年真题 【问题1】 【问题2】 2011 年真题 【问题1】 骚戴理解:首先要知道这样的题目没有可靠性,只有可用性,更没有容错性,这里我(3)写成了i,而不是f,仔…...

微信小程序面试题之理论篇
本文内容,来源于极客学院的分享,这里只做引用。 说说你对微信小程序的理解?优缺点? 背景 小程序与H5 优缺点 优点:缺点: 说说微信小程序的生命周期函数有哪些? 应用的生命周期页面的生命期组件的生命周期执行过程 应…...

C++前缀和算法的应用:统计上升四元组
C前缀和算法的应用:统计上升四元组 本文涉及的基础知识点 C算法:前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 题目 给你一个长度为 n 下标从 0 开始的整数数组 nums ,它包含 1 到 n 的所有数字,请你返回上…...

华泰证券:新奥能源:零售气待恢复,泛能与智家仍是亮点
来源:猛兽财经 作者:猛兽财经 猛兽财经获悉,由于新奥能源(02688)发布三季度经营数据: 1-3Q23:天然气零售量yoy-4.7%,燃气批发量yoy17.6%,综合能源销量yoy34.2%ÿ…...

FPGA与ASIC有什么差异?二者该如何选用?
前言 对于一个数字电路的新手来说,这可能是会经常遇到的一个问题:FPGA和ASIC之间的区别是什么? 接下来本文将尝试讲解 “什么是FPGA?” 和 “什么是ASIC?”,然后讲述一些关于FPGA和ASIC的问题,例如它们之间…...

Kotlin run 用法
Kotlin 中的 .run 函数可以用于不同的场景,下面是一些常见的用法: 执行代码块并返回结果: val result run {// 在这里编写一些代码逻辑// 返回最后一个表达式的结果"Hello, Kotlin" }println(result) // 输出:Hello, …...

iZotope RX 10(音频修复和增强工具)
iZotope RX 10是一款音频修复和增强软件,主要特点包括: 声音修复:iZotope RX 10可以去除不良噪音、杂音、吱吱声等,使音频变得更加清晰干净。音频增强:iZotope RX 10支持对音频进行音量调节、均衡器、压缩器、限制器等…...

MES 价值点之数据追随
在现代制造业中,数据追溯已经越来越得到重视,特别是那些推行精益生产的企业重要性就更加突出了,而制造执行系统(MES)作为一种关键的生产管理工具,是能很好的为制造企业提供数据追溯功能。今天,和…...

yolo8制作自己的数据集训练和预测分割
一、训练coco128-seg数据集,增加一个类别 coco128-seg数据集下载: github链接 csdn链接 1、修改两个配置文件 (1)、修改"E:\python\ultralytics-main\ultralytics\cfg\datasets\coco128-seg.yaml"路径下的coco128-seg.yaml数据集配置文件,可以拷贝出来 修改数…...

分享一下怎么做一个同城配送小程序
如何制作一个同城配送小程序:功能特点、使用指南及未来展望 一、引言 随着互联网的快速发展,人们对于生活服务的需求越来越高。同城配送作为连接消费者与商家的桥梁,越来越受到人们的关注。本文将详细介绍如何制作一个同城配送小程序&#…...

Qt 中model/View 架构 详解,以及案例实现相薄功能
model/View 架构 导读 我们的系统需要显示大量数据,比如从数据库中读取数据,以自己的方式显示在自己的应用程序的界面中。早期的 Qt 要实现这个功能,需要定义一个组件,在这个组件中保存一个数据对象,比如一个列表。我们对这个列表进行查找、插入等的操作,或者把修改…...

提高微星笔记本Linux下散热性能,MSI-EC 驱动新补丁发布
导读近日消息,今年早些时候,Linux 6.4 中添加了 MSI-EC 驱动程序,允许对 Linux 系统微星笔记本电脑进行更多控制。 MSI-EC 驱动程序近日迎来新补丁,为微星笔记本带来 Cooler Boost 功能。该功能允许提高笔记本电脑的风扇转速&…...