ElasticSearch基础学习(SpringBoot集成ES)

一、概述

什么是ElasticSearch?

ElasticSearch,简称为ES, ES是一个开源的高扩展的分布式全文搜索引擎

它可以近乎实时的存储、检索数据;本身扩展性很好,可以扩展到上百台服务器,处理PB级别的数据。

ES也使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。

ES核心概念

知道了ES是什么后,接下来还需要知道ES是如何存储数据,数据结构是什么,又是如何实现搜索的呢?

学习这些之前需要先了解一些ElasticSearch的相关概念。

ElasticSearch是面向文档型数据库

相信学习过MySql的同学都知道,MySql是关系型数据库,那么ES与关系型数据库有什么区别呢?

下面做一下简单的对比:

关系型数据库(MySql、Oracle等)ElasticSearch
数据库(database)索引(indices)
表(tables)类型(types)
行(rows)文档(documents)
列(columns)字段(fields)

说明:ElasticSearch(集群)中可以包含多个索引(数据库),每个索引中可以包含多个类型(表),每个类型下又包含多 个文档(行),每个文档中又包含多个字段(列)。

物理设计

ElasticSearch 在后台把每个索引划分成多个分片,每份分片可以在集群中的不同服务器间迁移。

逻辑设计

一个索引类型中,包含多个文档,比如说文档1,文档2,文档3。

当我们索引一篇文档时,可以通过这样的一个顺序找到它: 索引 ▷ 类型 ▷ 文档ID ,通过这个组合我们就能索引到某个具体的文档。 注意:ID不必是整数,实际上它是个字符串

索引

索引是映射类型的容器,elasticsearch中的索引是一个非常大的文档集合。索引存储了映射类型的字段和其他设置。 然后它们被存储到了各个分片上了。 我们来研究下分片是如何工作的。

物理设计 :节点和分片 如何工作

一个集群至少有一个节点,而一个节点就是一个elasricsearch进程,节点可以有多个索引默认的,如果你创建索引,那么索引将会有个5个分片 ( primary shard ,又称主分片 ) 构成的,每一个主分片会有一个副本 ( replica shard ,又称复制分片 )

上图是一个有3个节点的集群,可以看到主分片和对应的复制分片都不会在同一个节点内,这样有利于某个节点挂掉 了,数据也不至于丢失。 实际上,一个分片是一个Lucene索引,一个包含倒排索引的文件目录,倒排索引的结构使得elasticsearch在不扫描全部文档的情况下,就能告诉你哪些文档包含特定的关键字。 其中,倒排索引又是什么呢?

倒排索引

elasticsearch使用的是一种称为倒排索引的结构,采用Lucene倒排索作为底层。这种结构适用于快速的全文搜索, 一个索引由文档中所有不重复的列表构成,对于每一个词,都有一个包含它的文档列表。 例如,现在有两个文档, 每个文档包含如下内容:

 
  1. Study every day, good good up to forever # 文档1包含的内容
  2. To forever, study every day, good good up # 文档2包含的内容

为了创建倒排索引,我们首先要将每个文档拆分成独立的词(或称为词条或者tokens),然后创建一个包含所有不重复的词条的排序列表,然后列出每个词条出现在哪个文档 :

termdoc_1doc_2
Studyx
Toxx
every
forever
day
studyx
good
every
tox
up

现在,我们试图搜索 to forever,只需要查看包含每个词条的文档

termdoc_1doc_2
to×
forever
total21

两个文档都匹配,但是第一个文档比第二个匹配程度更高。如果没有别的条件,现在,这两个包含关键字的文档都将返回。

再来看一个示例,比如我们通过博客标签来搜索博客文章。那么倒排索引列表就是这样的一个结构 :

如果要搜索含有 python 标签的文章,那相对于查找所有原始数据而言,查找倒排索引后的数据将会快的多。只需要 查看标签这一栏,然后获取相关的文章ID即可。

ElasticSearch的索引和Lucene的索引对比

在elasticsearch中, 索引这个词被频繁使用,这就是术语的使用。 在elasticsearch中,索引被分为多个分片,每份分片是一个Lucene的索引。所以一个elasticsearch索引是由多个Lucene索引组成的

类型

类型是文档的逻辑容器,就像关系型数据库一样,表格是行的容器。 类型中对于字段的定义称为映射,比如 name 映射为字符串类型。

我们说文档是无模式的,它们不需要拥有映射中所定义的所有字段,比如新增一个字段,那么elasticsearch是怎么做的呢?elasticsearch会自动的将新字段加入映射,但是这个字段的不确定它是什么类型,elasticsearch就开始猜,如果这个值是18,那么elasticsearch会认为它是整形。 但是elasticsearch也可能猜不对, 所以最安全的方式就是提前定义好所需要的映射,这点跟关系型数据库殊途同归了,先定义好字段,然后再使用。

文档

之前说elasticsearch是面向文档的,那么就意味着索引和搜索数据的最小单位是文档。

elasticsearch中,文档有几个重要属性 :

  • 自我包含,一篇文档同时包含字段和对应的值,也就是同时包含 key:value!
  • 可以是层次型的,一个文档中包含自文档,复杂的逻辑实体就是这么来的!
  • 灵活的结构,文档不依赖预先定义的模式,我们知道关系型数据库中,要提前定义字段才能使用,在elasticsearch中,对于字段是非常灵活的,有时候,我们可以忽略该字段,或者动态的添加一个新的字段。

尽管我们可以随意的新增或者忽略某个字段,但是,每个字段的类型非常重要,比如一个年龄字段类型,可以是字符串也可以是整形。因为elasticsearch会保存字段和类型之间的映射及其他的设置。这种映射具体到每个映射的每种类型,这也是为什么在elasticsearch中,类型有时候也称为映射类型。

二、ES基础操作

IK分词器插件

什么是IK分词器?

分词:即把一段中文或者别的划分成一个个的关键字,我们在搜索时候会把自己的信息进行分词,会把数据库中或者索引库中的数据进行分词,然后进行一个匹配操作。

默认的中文分词是将每个字看成一个词,比如 “我爱学习” 会被分为"我","爱","学","习",这显然是不符合要求的,所以我们需要安装中文分词器ik来解决这个问题。

IK分词器安装步骤

1、下载ik分词器的包,Github地址:GitHub - medcl/elasticsearch-analysis-ik: The IK Analysis plugin integrates Lucene IK analyzer into elasticsearch, support customized dictionary. (版本要对应)

2、下载后解压,并将目录拷贝到ElasticSearch根目录下的 plugins 目录中。

3、重新启动 ElasticSearch 服务,在启动过程中,你可以看到正在加载"analysis-ik"插件的提示信息,服务启动后,在命令行运行elasticsearch-plugin list 命令,确认 ik 插件安装成功。

IK提供了两个分词算法:ik_smart 和 ik_max_word,其中 ik_smart为最少切分,ik_max_word为最细粒度划分!

  • ik_max_word : 细粒度分词,会穷尽一个语句中所有分词可能。
  • ik_smart : 粗粒度分词,优先匹配最长词,只有1个词!

如果某些词语,在默认的词库中不存在,比如我们想让“我爱学习”被识别是一个词,这时就需要我们编辑自定义词库

步骤:

(1)进入elasticsearch/plugins/ik/config目录

(2)新建一个my.dic文件,编辑内容:

 
  1. 我爱学习

(3)修改IKAnalyzer.cfg.xml(在ik/config目录下)

 
  1. <properties>
  2. <comment>IK Analyzer 扩展配置</comment>
  3. <!-- 用户可以在这里配置自己的扩展字典 -->
  4. <entry key="ext_dict">my.dic</entry>
  5. <!-- 用户可以在这里配置自己的扩展停止词字典 -->
  6. <entry key="ext_stopwords"></entry>
  7. </properties>

注意:修改完配置后,需要重新启动elasticsearch。

增删改查基本命令

Rest风格说明

一种软件架构风格,而不是标准,只是提供了一组设计原则和约束条件。它主要用于客户端和服务器交互类的软件。基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制。

基本Rest命令说明(增、删、改、查命令):

methodur地址描述
PUTlocalhost:9200/索引名称/类型名称/文档id创建文档(指定文档id)
POSTlocalhost:9200/索引名称/类型名称创建文档(随机文档id)
POSTlocalhost:9200/索引名称/类型名称/文档id/_update修改文档
DELETElocalhost:9200/索名称/类型名称/文档id删除文档
GETlocalhost:9200/索引名称/类型名称/文档id查询文档通过文档id
POSTlocalhost:9200/索引名称/类型名称/_search查询所有数据

三、SpringBoot集成ES

1、新建项目

新建一个springboot(2.2.5版)项目 elasticsearch-demo ,导入web依赖即可。

2、配置依赖

配置elasticsearch的依赖:

 
  1. <properties>
  2. <java.version>1.8</java.version>
  3. <!-- 这里SpringBoot默认配置的版本不匹配,我们需要自己配置版本! -->
  4. <elasticsearch.version>7.6.1</elasticsearch.version>
  5. </properties>
  6. <dependency>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
  9. </dependency>

3、编写配置类

编写elasticsearch的配置类,提供RestHighLevelClient这个bean来进行操作。

 
  1. package com.hzx.config;
  2. import org.apache.http.HttpHost;
  3. import org.elasticsearch.client.RestClient;
  4. import org.elasticsearch.client.RestHighLevelClient;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. @Configuration
  8. public class ElasticsearchClientConfig {
  9. @Bean
  10. public RestHighLevelClient restHighLevelClient() {
  11. RestHighLevelClient client = new RestHighLevelClient(
  12. RestClient.builder(new HttpHost("127.0.0.1", 9200, "http")));
  13. return client;
  14. }
  15. }

4、配置工具类

封装ES常用方法工具类

 
  1. package com.hzx.utils;
  2. import com.alibaba.fastjson.JSON;
  3. import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
  4. import org.elasticsearch.action.bulk.BulkRequest;
  5. import org.elasticsearch.action.bulk.BulkResponse;
  6. import org.elasticsearch.action.delete.DeleteRequest;
  7. import org.elasticsearch.action.delete.DeleteResponse;
  8. import org.elasticsearch.action.get.GetRequest;
  9. import org.elasticsearch.action.get.GetResponse;
  10. import org.elasticsearch.action.index.IndexRequest;
  11. import org.elasticsearch.action.index.IndexResponse;
  12. import org.elasticsearch.action.search.SearchRequest;
  13. import org.elasticsearch.action.search.SearchResponse;
  14. import org.elasticsearch.action.support.master.AcknowledgedResponse;
  15. import org.elasticsearch.action.update.UpdateRequest;
  16. import org.elasticsearch.action.update.UpdateResponse;
  17. import org.elasticsearch.client.RequestOptions;
  18. import org.elasticsearch.client.RestHighLevelClient;
  19. import org.elasticsearch.client.indices.CreateIndexRequest;
  20. import org.elasticsearch.client.indices.CreateIndexResponse;
  21. import org.elasticsearch.client.indices.GetIndexRequest;
  22. import org.elasticsearch.common.unit.TimeValue;
  23. import org.elasticsearch.common.xcontent.XContentType;
  24. import org.elasticsearch.index.query.QueryBuilders;
  25. import org.elasticsearch.rest.RestStatus;
  26. import org.elasticsearch.search.builder.SearchSourceBuilder;
  27. import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.beans.factory.annotation.Qualifier;
  30. import org.springframework.stereotype.Component;
  31. import java.io.IOException;
  32. import java.util.List;
  33. import java.util.concurrent.TimeUnit;
  34. @Component
  35. public class EsUtils<T> {
  36. @Autowired
  37. @Qualifier("restHighLevelClient")
  38. private RestHighLevelClient client;
  39. /**
  40. * 判断索引是否存在
  41. *
  42. * @param index
  43. * @return
  44. * @throws IOException
  45. */
  46. public boolean existsIndex(String index) throws IOException {
  47. GetIndexRequest request = new GetIndexRequest(index);
  48. boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);
  49. return exists;
  50. }
  51. /**
  52. * 创建索引
  53. *
  54. * @param index
  55. * @throws IOException
  56. */
  57. public boolean createIndex(String index) throws IOException {
  58. CreateIndexRequest request = new CreateIndexRequest(index);
  59. CreateIndexResponse createIndexResponse = client.indices()
  60. .create(request, RequestOptions.DEFAULT);
  61. return createIndexResponse.isAcknowledged();
  62. }
  63. /**
  64. * 删除索引
  65. *
  66. * @param index
  67. * @return
  68. * @throws IOException
  69. */
  70. public boolean deleteIndex(String index) throws IOException {
  71. DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(index);
  72. AcknowledgedResponse response = client.indices()
  73. .delete(deleteIndexRequest, RequestOptions.DEFAULT);
  74. return response.isAcknowledged();
  75. }
  76. /**
  77. * 判断某索引下文档id是否存在
  78. *
  79. * @param index
  80. * @param id
  81. * @return
  82. * @throws IOException
  83. */
  84. public boolean docExists(String index, String id) throws IOException {
  85. GetRequest getRequest = new GetRequest(index, id);
  86. //只判断索引是否存在不需要获取_source
  87. getRequest.fetchSourceContext(new FetchSourceContext(false));
  88. getRequest.storedFields("_none_");
  89. boolean exists = client.exists(getRequest, RequestOptions.DEFAULT);
  90. return exists;
  91. }
  92. /**
  93. * 添加文档记录
  94. *
  95. * @param index
  96. * @param id
  97. * @param t 要添加的数据实体类
  98. * @return
  99. * @throws IOException
  100. */
  101. public boolean addDoc(String index, String id, T t) throws IOException {
  102. IndexRequest request = new IndexRequest(index);
  103. request.id(id);
  104. //timeout
  105. request.timeout(TimeValue.timeValueSeconds(1));
  106. request.timeout("1s");
  107. request.source(JSON.toJSONString(t), XContentType.JSON);
  108. IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);
  109. RestStatus Status = indexResponse.status();
  110. return Status == RestStatus.OK || Status == RestStatus.CREATED;
  111. }
  112. /**
  113. * 根据id来获取记录
  114. *
  115. * @param index
  116. * @param id
  117. * @return
  118. * @throws IOException
  119. */
  120. public GetResponse getDoc(String index, String id) throws IOException {
  121. GetRequest request = new GetRequest(index, id);
  122. GetResponse getResponse = client.get(request,RequestOptions.DEFAULT);
  123. return getResponse;
  124. }
  125. /**
  126. * 批量添加文档记录
  127. * 没有设置id ES会自动生成一个,如果要设置 IndexRequest的对象.id()即可
  128. *
  129. * @param index
  130. * @param list
  131. * @return
  132. * @throws IOException
  133. */
  134. public boolean bulkAdd(String index, List<T> list) throws IOException {
  135. BulkRequest bulkRequest = new BulkRequest();
  136. //timeout
  137. bulkRequest.timeout(TimeValue.timeValueMinutes(2));
  138. bulkRequest.timeout("2m");
  139. for (int i = 0; i < list.size(); i++) {
  140. bulkRequest.add(new IndexRequest(index).source(JSON.toJSONString(list.get(i))));
  141. }
  142. BulkResponse bulkResponse = client.bulk(bulkRequest,RequestOptions.DEFAULT);
  143. return !bulkResponse.hasFailures();
  144. }
  145. /**
  146. * 更新文档记录
  147. * @param index
  148. * @param id
  149. * @param t
  150. * @return
  151. * @throws IOException
  152. */
  153. public boolean updateDoc(String index, String id, T t) throws IOException {
  154. UpdateRequest request = new UpdateRequest(index, id);
  155. request.doc(JSON.toJSONString(t));
  156. request.timeout(TimeValue.timeValueSeconds(1));
  157. request.timeout("1s");
  158. UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
  159. return updateResponse.status() == RestStatus.OK;
  160. }
  161. /**
  162. * 删除文档记录
  163. *
  164. * @param index
  165. * @param id
  166. * @return
  167. * @throws IOException
  168. */
  169. public boolean deleteDoc(String index, String id) throws IOException {
  170. DeleteRequest request = new DeleteRequest(index, id);
  171. //timeout
  172. request.timeout(TimeValue.timeValueSeconds(1));
  173. request.timeout("1s");
  174. DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT);
  175. return deleteResponse.status() == RestStatus.OK;
  176. }
  177. /**
  178. * 根据某字段来搜索
  179. *
  180. * @param index
  181. * @param field
  182. * @param key 要收搜的关键字
  183. * @throws IOException
  184. */
  185. public void search(String index, String field, String key, Integer
  186. from, Integer size) throws IOException {
  187. SearchRequest searchRequest = new SearchRequest(index);
  188. SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
  189. sourceBuilder.query(QueryBuilders.termQuery(field, key));
  190. //控制搜素
  191. sourceBuilder.from(from);
  192. sourceBuilder.size(size);
  193. //最大搜索时间。
  194. sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
  195. searchRequest.source(sourceBuilder);
  196. SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
  197. System.out.println(JSON.toJSONString(searchResponse.getHits()));
  198. }
  199. }

5、工具类API测试

测试创建索引:

 
  1. @Test
  2. void testCreateIndex() throws IOException {
  3. CreateIndexRequest request = new CreateIndexRequest("test_index");
  4. CreateIndexResponse createIndexResponse=restHighLevelClient.indices()
  5. .create(request,RequestOptions.DEFAULT);
  6. System.out.println(createIndexResponse);
  7. }

测试获取索引:

 
  1. @Test
  2. void testExistsIndex() throws IOException {
  3. GetIndexRequest request = new GetIndexRequest("test_index");
  4. boolean exists = restHighLevelClient.indices()
  5. .exists(request,RequestOptions.DEFAULT);
  6. System.out.println(exists);
  7. }

测试删除索引:

 
  1. @Test
  2. void testDeleteIndexRequest() throws IOException {
  3. DeleteIndexRequest deleteIndexRequest = new
  4. DeleteIndexRequest("test_index");
  5. AcknowledgedResponse response = restHighLevelClient.indices()
  6. .delete(deleteIndexRequest,
  7. RequestOptions.DEFAULT);
  8. System.out.println(response.isAcknowledged());
  9. }

测试添加文档记录:

创建一个实体类User

 
  1. @Data
  2. @AllArgsConstructor
  3. @NoArgsConstructor
  4. @Component
  5. public class User {
  6. private String name;
  7. private int age;
  8. }

测试添加文档记录

 
  1. @Test
  2. void testAddDocument() throws IOException {
  3. // 创建对象
  4. User user = new User("zhangsan", 3);
  5. // 创建请求
  6. IndexRequest request = new IndexRequest("test_index");
  7. // 规则
  8. request.id("1");
  9. request.timeout(TimeValue.timeValueSeconds(1));
  10. request.timeout("1s");
  11. request.source(JSON.toJSONString(user), XContentType.JSON);
  12. // 发送请求
  13. IndexResponse indexResponse = restHighLevelClient.index(request,
  14. RequestOptions.DEFAULT);
  15. System.out.println(indexResponse.toString());
  16. RestStatus Status = indexResponse.status();
  17. System.out.println(Status == RestStatus.OK || Status ==
  18. RestStatus.CREATED);
  19. }

测试:判断某索引下文档id是否存在

 
  1. @Test
  2. void testIsExists() throws IOException {
  3. GetRequest getRequest = new GetRequest("test_index","1");
  4. // 不获取_source上下文 storedFields
  5. getRequest.fetchSourceContext(new FetchSourceContext(false));
  6. getRequest.storedFields("_none_");
  7. // 判断此id是否存在!
  8. boolean exists = restHighLevelClient.exists(getRequest,
  9. RequestOptions.DEFAULT);
  10. System.out.println(exists);
  11. }

测试:根据id获取文档记录

 
  1. @Test
  2. void testGetDocument() throws IOException {
  3. GetRequest getRequest = new GetRequest("test_index","3");
  4. GetResponse getResponse = restHighLevelClient.get(getRequest,RequestOptions.DEFAULT);
  5. // 打印文档内容
  6. System.out.println(getResponse.getSourceAsString());
  7. System.out.println(getResponse);
  8. }

测试:更新文档记录

 
  1. @Test
  2. void testUpdateDocument() throws IOException {
  3. UpdateRequest request = new UpdateRequest("test_index","1");
  4. request.timeout(TimeValue.timeValueSeconds(1));
  5. request.timeout("1s");
  6. User user = new User("zhangsan", 18);
  7. request.doc(JSON.toJSONString(user), XContentType.JSON);
  8. UpdateResponse updateResponse = restHighLevelClient.update(request, RequestOptions.DEFAULT);
  9. System.out.println(updateResponse.status() == RestStatus.OK);
  10. }

测试:删除文档记录

 
  1. @Test
  2. void testDelete() throws IOException {
  3. DeleteRequest request = new DeleteRequest("test_index","3");
  4. //timeout
  5. request.timeout(TimeValue.timeValueSeconds(1));
  6. request.timeout("1s");
  7. DeleteResponse deleteResponse = restHighLevelClient.delete(
  8. request, RequestOptions.DEFAULT);
  9. System.out.println(deleteResponse.status() == RestStatus.OK);
  10. }

测试:批量添加文档

 
  1. @Test
  2. void testBulkRequest() throws IOException {
  3. BulkRequest bulkRequest = new BulkRequest();
  4. //timeout
  5. bulkRequest.timeout(TimeValue.timeValueMinutes(2));
  6. bulkRequest.timeout("2m");
  7. ArrayList<User> userList = new ArrayList<>();
  8. userList.add(new User("zhangsan1",3));
  9. userList.add(new User("zhangsan2",3));
  10. userList.add(new User("zhangsan3",3));
  11. userList.add(new User("lisi1",3));
  12. userList.add(new User("lisi2",3));
  13. userList.add(new User("lisi3",3));
  14. for (int i =0;i<userList.size();i++){
  15. bulkRequest.add(new IndexRequest("test_index").id(""+(i+1))
  16. .source(JSON.toJSONString(userList.get(i)),XContentType.JSON));
  17. }
  18. // bulk
  19. BulkResponse bulkResponse = restHighLevelClient.bulk(bulkRequest,RequestOptions.DEFAULT);
  20. System.out.println(!bulkResponse.hasFailures());
  21. }

查询测试:

 
  1. /**
  2. * 使用QueryBuilder
  3. * termQuery("key", obj) 完全匹配
  4. * termsQuery("key", obj1, obj2..) 一次匹配多个值
  5. * matchQuery("key", Obj) 单个匹配, field不支持通配符, 前缀具高级特性
  6. * multiMatchQuery("text", "field1", "field2"..); 匹配多个字段, field有通配符忒行
  7. * matchAllQuery(); 匹配所有文件
  8. */
  9. @Test
  10. void testSearch() throws IOException {
  11. SearchRequest searchRequest = new SearchRequest("test_index");
  12. SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
  13. // TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("name","zhangsan1");
  14. MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
  15. sourceBuilder.query(matchAllQueryBuilder);
  16. sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
  17. searchRequest.source(sourceBuilder);
  18. SearchResponse response = restHighLevelClient.search(searchRequest,RequestOptions.DEFAULT);
  19. System.out.println(JSON.toJSONString(response.getHits()));
  20. System.out.println("================查询高亮显示==================");
  21. for (SearchHit documentFields : response.getHits().getHits()) {
  22. System.out.println(documentFields.getSourceAsMap());
  23. }
  24. }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/35783.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

最新版Flink CDC MySQL同步MySQL(一)

1.概述 Flink CDC 是Apache Flink 的一组源连接器&#xff0c;使用变更数据捕获 (CDC) 从不同数据库中获取变更。Apache Flink 的 CDC Connectors集成 Debezium 作为捕获数据更改的引擎。所以它可以充分发挥 Debezium 的能力。 2.支持的连接器 连接器数据库驱动mongodb-cdc…

支持跨语言、人声狗吠互换,仅利用最近邻的简单语音转换模型有多神奇

AI 语音转换真的越复杂越好吗&#xff1f;本文就提出了一个方法简单但同样强大的语言转换模型&#xff0c;与基线方法相比自然度和清晰度毫不逊色&#xff0c;相似度更是大大提升。 AI 参与的语音世界真神奇&#xff0c;既可以将一个人的语音换成任何其他人的语音&#xff0c;…

【VsCode远程开发】Windows SSH远程连接Linux服务器 - 无公网IP内网穿透

文章目录 前言视频教程1、安装OpenSSH2、vscode配置ssh3. 局域网测试连接远程服务器4. 公网远程连接4.1 ubuntu安装cpolar内网穿透4.2 创建隧道映射4.3 测试公网远程连接 5. 配置固定TCP端口地址5.1 保留一个固定TCP端口地址5.2 配置固定TCP端口地址5.3 测试固定公网地址远程 转…

使用Python爬虫和数据可视化,揭示人口大国历年人数的变迁

前言 人口大国通常在全球人口排名中位居前列&#xff0c;其人口数量远远超过其他国家。而印度和中国这两个国家的人口数量均已经超过14亿&#xff0c;而当前全球的人口总数也不过刚刚突破80亿而已&#xff0c;妥妥的天花板级别存在。或许是中国和印度在人口方面的表现太过“耀…

【Python】Python基础知识总结

&#x1f389;欢迎来到Python专栏~Python基础知识总结 ☆* o(≧▽≦)o *☆嗨~我是小夏与酒&#x1f379; ✨博客主页&#xff1a;小夏与酒的博客 &#x1f388;该系列文章专栏&#xff1a;Python学习专栏 文章作者技术和水平有限&#xff0c;如果文中出现错误&#xff0c;希望…

MySQL基本查询与内置函数

目录 聚合函数 分组查询 内置函数 日期函数 字符串函数 数学函数 聚合函数 COUNT&#xff1a;返回查询到的数据的数量 SUM&#xff1a;返回查询到的数据的总和&#xff08;数字&#xff09; AVG&#xff1a;返回数据的平均值 MAX&#xff1a;返回查询到的数据的最大值 MIN&a…

微软MFC技术中消息的分类

我是荔园微风&#xff0c;作为一名在IT界整整25年的老兵&#xff0c;今天来聊聊MFC技术中消息的分类。 微软Windows中的消息虽然很多&#xff0c;但是种类并不繁杂&#xff0c;大体上有3种&#xff1a;窗口消息、命令消息和控件通知消息。 窗口消息 窗口消息是系统中最为常见…

离线环境下安装微软Visual Studio 2022 生成工具

1. 前言 最近&#xff0c;在学习cython的时候&#xff0c;需要安装windows下的C/C编译、链接工具。开始觉得传统的msvc太大了&#xff0c;想要尝试Mingw&#xff0c;但是都是编译错误。无奈之下&#xff0c;还是要安装msvc。 微软提供了Visual Studio 2022 Build Tools &…

12.JavaWeb-Node.js+创建Vue项目

1.Node.js的概念 传统的Web服务器中&#xff0c;每个请求都会创建一个线程&#xff0c;这会导致线程数的增加&#xff0c;从而影响服务器的性能和扩展性&#xff0c;Ryan Dahl借助Chrome的V8引擎提供的能力实现了Node.js——可以在服务端运行的JavaScript&#xff08;可以把Nod…

高数(下) 第九章:多元函数微分学 及其应用

文章目录 Ch9. 多元函数微分学 及其应用(一) 二重极限&#xff08;二元函数的极限&#xff09;(二) 多元函数的连续性(三) 偏导数1.偏导数的定义2.二阶混合偏导数相等3.变限积分求偏导 (四) 二元可微&#xff1a;全增量、全微分(五) 多元复合函数 求导法则(六) 多元隐函数 的求…

Mac如何在终端使用diskutil命令装载和卸载推出外接硬盘

最近用 macOS 装载外接硬盘的时候&#xff0c;使用mount死活装不上&#xff0c;很多文章也没详细的讲各种情况&#xff0c;所以就写一篇博客来记录一下。 如何装载和卸载硬盘&#xff08;或者说分区&#xff09; mount和umount是在 macOS 上是不能用的&#xff0c;如果使用会…

R语言——字符串处理

paste(abc, def, gh, sep ) #粘贴字符串 substr(abcdefg, 2, 3) # 取特定字符串 gsub(abc, , c(abc, abcc, abcbc)) # 将字符串中abc替换为空 strsplit(a;b;c, ;, fixed T) # 按照;切分字符串 strsplit(a222b2.2c, 2.2, fixed F) # 按照正则表达式分隔&#xff0c;这里的.是…

解放运营人员:钡铼技术S475物联网网关实现养殖环境的远程监控与告警

在养殖行业中&#xff0c;对环境参数的精确监测与控制至关重要。然而&#xff0c;传统的监测方法往往存在诸多痛点&#xff0c;如数据采集不准确、传输速度慢、可视化效果差等。为了解决这些问题&#xff0c;钡铼技术公司推出了其旗舰产品——S475多功能RTU&#xff0c;该产品在…

外包干了2个月,技术退步明显...

先说一下自己的情况&#xff0c;大专生&#xff0c;18年通过校招进入湖南某软件公司&#xff0c;干了接近4年的功能测试&#xff0c;今年年初&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落!而我已经在一个企业干了四年的功能测试…

云原生之深入解析K8S的请求和限制

一、Kubernetes 限制和请求 在 Kubernetes 中使用容器时&#xff0c;了解涉及的资源是什么以及为何需要它们很重要。有些进程比其它进程需要更多的 CPU 或内存&#xff0c;这很关键&#xff0c;永远不应该让进程饥饿&#xff0c;知道了这一点&#xff0c;那么应该正确配置容器…

Visual Studio 2017下的C++开发环境搭建

Visual Studio 是Microsoft旗下的开发工具包系列产品&#xff0c;是一个基本完整的开发工具集&#xff0c;它包括整个软件生命周期中所需要的大部分工具&#xff0c;如UML工具、代码管控工具、集成开发环境(IDE)等等&#xff0c;是最流行的Windows平台应用程序的集成开发环境。…

【Springboot集成Neo4j完整版教程】

&#x1f680; Neo4j &#x1f680; &#x1f332; 算法刷题专栏 | 面试必备算法 | 面试高频算法 &#x1f340; &#x1f332; 越难的东西,越要努力坚持&#xff0c;因为它具有很高的价值&#xff0c;算法就是这样✨ &#x1f332; 作者简介&#xff1a;硕风和炜&#xff0c;C…

低代码平台的价格范围及购买成本分析

Zoho Creator是一款强大而灵活的低代码应用程序开发平台&#xff0c;可帮助企业快速、高效地创建各种应用程序。但是&#xff0c;很多人可能会担心它的价格问题。在这篇文章中&#xff0c;我们将深入探讨Zoho Creator的定价策略和计划&#xff0c;以帮助您更好地理解其价格结构…

vue+elementui实现联想购物商城,样式美观大方

目录 一、首页效果图对比 1.联想商城首页截图&#xff1a; 2.作者项目效果图&#xff1a; 二、商品详情效果图对比 1.联想官方截图&#xff1a; 2.作者项目截图&#xff1a; 三、项目实现 1.数据分离维护 2.首页推荐列表数据处理 3.商品详情数据动态获取完成交互 4.商品详…

Spring MVC是什么?详解它的组件、请求流程及注解

作者&#xff1a;Insist-- 个人主页&#xff1a;insist--个人主页 作者会持续更新网络知识和python基础知识&#xff0c;期待你的关注 前言 本文将讲解Spring MVC是什么&#xff0c;它的优缺点与九大组件&#xff0c;以及它的请求流程与常用的注解。 目录 一、Spring MVC是什…