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

Elasticsearch-06-Elasticsearch Java API Client

前言

简介

在 Elasticsearch7.15版本之后,Elasticsearch官方将它的高级客户端 RestHighLevelClient标记为弃用状态。同时推出了全新的 Java API客户端 Elasticsearch Java API Client,该客户端也将在 Elasticsearch8.0及以后版本中成为官方推荐使用的客户端。

Elasticsearch Java API Client 支持除 Vector tile search API 和 Find structure API 之外的所有 Elasticsearch API。且支持所有API数据类型,并且不再有原始JsonValue属性。它是针对Elasticsearch8.0及之后版本的客户端,所以我们需要学习新的Elasticsearch Java API Client的使用方法。

为什么要抛弃High Level Rest:

  • 客户端"too heavy",相关依赖超过 30 MB,且很多都是非必要相关的;api 暴露了很多服务器内部接口

  • 一致性差,仍需要大量的维护工作。

  • 客户端没有集成 json/object 类型映射,仍需要自己借助字节缓存区实现。

Java API Client最明显的特征:

  • 支持lambda表达式操作ES
  • 支持Builder建造者模式操作ES,链式代码具有较强可读性.
  • 应用程序类能够自动映射为Mapping.
  • 所有Elasticsearch API的强类型请求和响应。
  • 所有API的阻塞和异步版本
  • 将协议处理委托给http客户端(如Java低级REST客户端),该客户端负责处理所有传输级问题:HTTP连接池、重试、节点发现等。

官方地址

https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/indexing.html

简单使用

1:导包

这里记住你的elasticsearch-java必须对应你电脑上装的ES版本

	<dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>7.17.6</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.12.3</version></dependency><dependency><groupId>jakarta.json</groupId><artifactId>jakarta.json-api</artifactId><version>2.0.1</version></dependency>

2:开启链接

        //创建一个低级的客户端final RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();//创建JSON对象映射器final RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());//创建API客户端final ElasticsearchClient client = new ElasticsearchClient(transport);

3:关闭链接

        client.shutdown();transport.close();restClient.close();

4:完整代码

public class Client {public static void main(String[] args) throws IOException {//创建一个低级的客户端final RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();//创建JSON对象映射器final RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());//创建API客户端final ElasticsearchClient client = new ElasticsearchClient(transport);//查询所有索引-------------------------------------------------------------------------------------final GetIndexResponse response = client.indices().get(query -> query.index("_all"));final IndexState products = response.result().get("products");System.out.println(products.toString());//关闭client.shutdown();transport.close();restClient.close();}
}

JsonData类

原始JSON值。可以使用JsonpMapper将其转换为JSON节点树或任意对象。 此类型在API类型中用于没有静态定义类型或无法表示为封闭数据结构的泛型参数的值。 API客户端返回的此类实例保留对客户端的JsonpMapper的引用,并且可以使用to(class)转换为任意类型,而不需要显式映射器

我们一般在ES的DSL范围查询中会使用到!
核心方法:

  • to:将此对象转换为目标类。必须在创建时提供映射器
  • from:从读取器创建原始JSON值
  • of:从现有对象创建原始JSON值,以及用于进一步转换的映射器
  • deserialize:使用反序列化程序转换此对象。必须在创建时提供映射器

高阶使用

1:ES配置类

// 配置的前缀
@ConfigurationProperties(prefix = "elasticsearch") 
@Configuration
public class ESClientConfig {/*** 多个IP逗号隔开*/@Setterprivate String hosts;/*** 同步方式* * @return*/@Beanpublic ElasticsearchClient elasticsearchClient() {HttpHost[] httpHosts = toHttpHost();// Create the RestClient //RestClient restClient = RestClient.builder(httpHosts).build();RestClient restClient = RestClient.builder(httpHosts).setHttpClientConfigCallback(httpClientBuilder->httpClientBuilder.setDefaultHeaders(listOf(new BasicHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()))).addInterceptorLast((HttpResponseInterceptor) (response, context)-> response.addHeader("X-Elastic-Product", "Elasticsearch"))).build();// Create the transport with a Jackson mapperRestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());// create the API clientreturn new ElasticsearchClient(transport);}/*** 异步方式* * @return*/@Beanpublic ElasticsearchAsyncClient elasticsearchAsyncClient() {HttpHost[] httpHosts = toHttpHost();RestClient restClient = RestClient.builder(httpHosts).build();RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());return new ElasticsearchAsyncClient(transport);}/*** 解析配置的字符串hosts,转为HttpHost对象数组** @return*/private HttpHost[] toHttpHost() {if (!StringUtils.hasLength(hosts)) {throw new RuntimeException("invalid elasticsearch configuration. elasticsearch.hosts不能为空!");}// 多个IP逗号隔开String[] hostArray = hosts.split(",");HttpHost[] httpHosts = new HttpHost[hostArray.length];HttpHost httpHost;for (int i = 0; i < hostArray.length; i++) {String[] strings = hostArray[i].split(":");httpHost = new HttpHost(strings[0], Integer.parseInt(strings[1]), "http");httpHosts[i] = httpHost;}return httpHosts;}}

2:查询所有索引

//省略连接...final GetIndexResponse all = client.indices().get(query -> query.index("_all"));System.out.println(all.toString());
//省略关闭...

3:查询某个索引

        //查询某个索引final GetIndexResponse products = client.indices().get(query -> query.index("products"));System.err.println(products.toString());

4:创建索引

		//查询某个索引是否存在boolean exists = client.indices().exists(query -> query.index("products")).value();System.out.println(exists);if (exists) {System.err.println("索引已存在");} else {final CreateIndexResponse products = client.indices().create(builder -> builder.index("products"));System.err.println(products.acknowledged());}

5:删除指定索引

        //删除指定索引boolean exists = client.indices().exists(query -> query.index("products")).value();System.out.println(exists);if (exists) {DeleteIndexResponse response = client.indices().delete(query -> query.index("products"));System.err.println(response.acknowledged());} else {System.err.println("索引不存在");}

6:查询索引的映射

        //查询映射信息final GetIndexResponse response = client.indices().get(builder -> builder.index("produces"));System.err.println(response.result().get("produces").mappings());

7:创建索引指定映射

numberOfReplicas(“1”):设置副本
numberOfShards(“1”):设置分片

        //创建索引指定映射,分片和副本信息final CreateIndexResponse response = client.indices().create(builder ->builder.settings(indexSetting -> indexSetting.numberOfReplicas("1").numberOfShards("1")).mappings(map -> map.properties("name", propertyBuilder -> propertyBuilder.keyword(keywordProperty -> keywordProperty)).properties("price", propertyBuilder -> propertyBuilder.double_(doubleNumProperty -> doubleNumProperty)).properties("des", propertyBuilder -> propertyBuilder.text(textProperty -> textProperty.analyzer("ik_smart").searchAnalyzer("ik_smart")))).index("produces"));

8:创建文档

使用HashMap作为数据存储容器

        //创建文档//1.创建HashMap进行存储数据,文档要对应映射final HashMap<String, Object> doc = new HashMap<>();doc.put("name","辣条");doc.put("age",12);doc.put("id","11111");//2.将文档存入索引中final IndexResponse response = client.index(builder -> builder.index("produces").id(doc.get("id")).document(doc));System.err.println(response.version());

使用自定义类作为数据存储容器

实体类

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Produce {private String id;private String name;private double age;
}
        //创建文档final Produce produce = new Produce("123", "小明", 18);final IndexResponse response = client.index(builder -> builder.index("produces").id(produce.getId()).document(produce));System.err.println(response.version());

使用外部JSON数据创建

这里要注意我们需要使用StringReader进行读取时使用replace函数将设置的’改为",当然这在真实的业务中肯定不会有,因为真实业务中一定是标准的JSON数据,无需使用replace进行替换了

        //创建文档final StringReader input = new StringReader("{'name':'农夫三拳','price':3.00,'des':'农夫三拳有点甜'}".replace('\'', '"'));final IndexResponse response = client.index(builder -> builder.index("produces").id("44514").withJson(input));System.err.println(response.version());

9: 查询所有文档

 final SearchResponse<Object> response = client.search(builder -> builder.index("produces"), Object.class);final List<Hit<Object>> hits = response.hits().hits();hits.forEach(x-> System.err.println(x));

10:根据ID查询文档

使用HashMap对应查询

        //查询文档final GetResponse<Map> response = client.get(builder -> builder.index("produces").id("116677"), Map.class);final Map source = response.source();source.forEach((x,y)->{System.err.println(x+":"+y);});

使用自定义类对应查询

        final GetResponse<Produce> response1 = client.get(builder -> builder.index("produces").id("aabbcc123"), Produce.class);final Produce source1 = response1.source();System.err.println(source1.toString());

11:删除文档

        final GetResponse<Produce> response1 = client.get(builder -> builder.index("produces").id("aabbcc123"), Produce.class);final Produce source1 = response1.source();System.err.println(source1.toString());

12:修改文档

全覆盖

        //修改文档(覆盖)final Produce produce = new Produce("ccaabb123", "旺仔摇滚洞", "旺仔摇滚洞乱摇乱滚", 10.23D);final UpdateResponse<Produce> response = client.update(builder -> builder.index("produces").id("aabbcc123").doc(produce), Produce.class);System.err.println(response.shards().successful());

修改部分文档

区别在于我们需要设置.docAsUpsert(true)表明是修改部分而不是覆盖

        //修改文档(部分修改)
//        final Produce produce = new Produce("ccaabb123", "旺仔摇滚洞", "旺仔摇滚洞乱摇乱滚", 10.23D);final Produce produce = new Produce();produce.setName("旺仔摇不动");final UpdateResponse<Produce> response = client.update(builder -> builder.index("produces").id("aabbcc123").doc(produce).docAsUpsert(true), Produce.class);System.err.println(response.shards().successful());

13:批量操作

批量新增

		produceList.add(produce1);produceList.add(produce2);produceList.add(produce3);//构建BulkRequestfinal BulkRequest.Builder br = new BulkRequest.Builder();for (Produce produce : produceList) {br.operations(op->op.index(idx->idx.index("produces").id(produce.getSku()).document(produce)));}final BulkResponse response = client.bulk(br.build());

批量删除

List<BulkOperation> bulkOperations = new ArrayList<>();// 向集合中添加需要删除的文档id信息for (int i = 0; i < dto.getIds().size(); i++) {int finalI = i;bulkOperations.add(BulkOperation.of(b -> b.delete((d -> d.index(dto.getIndex()).id(dto.getIds().get(finalI))))));}// 调用客户端的bulk方法,并获取批量操作响应结果BulkResponse response = client.bulk(e -> e.index(dto.getIndex()).operations(bulkOperations));

DSL查询

1:matchAll查询所有文档

        //matchAllfinal SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.matchAll(v->v)), Produce.class);System.err.println(response.hits().hits());

2:match 根据字段查询

        //简单query方式查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.match(t ->t.field("name").query("龙虎万精油"))), Produce.class);System.err.println(response.hits().hits());

3:多id查询

        //多ID查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.ids(sid->sid.values("1000","1001"))), Produce.class);System.err.println(response.hits().hits());

4:term 不分词查询

        //term不分词条件查询final SearchResponse<Produce> response = client.search(builder -> builder.index("produces").query(q -> q.term(t -> t.field("name").value("风油精"))), Produce.class);System.err.println(response.hits().hits());

5:范围查询

        //范围查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.range(r ->r.field("price").gt(JsonData.of(5D)).lt(JsonData.of(15D)))),Produce.class);System.err.println(response.hits().hits());

6: 前缀查询

  final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.prefix(p->p.field("name").value("六"))),Produce.class);System.err.println(response.hits().hits());

7:匹配查询

//匹配查询

  final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.wildcard(w->w.field("name").value("风*"))),Produce.class);System.err.println(response.hits().hits());

?单字符匹配

        //匹配查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.wildcard(w->w.field("name").value("风?精"))),Produce.class);System.err.println(response.hits().hits());

8:模糊查询

        //模糊查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.fuzzy(f->f.field("name").value("六仙花露水"))),Produce.class);System.err.println(response.hits().hits());

9:多条件查询

使用bool关键字配合must,should,must_not

  • must:所有条件必须同时成立
  • must_not:所有条件必须同时不成立
  • should:所有条件中成立一个即可
        //多条件final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q ->q.bool(b ->b.must(t ->t.term(v ->v.field("name").value("旺仔摇不动"))).must(t2 ->t2.term(v2 ->v2.field("price").value(0.0D))))),Produce.class);System.err.println(response.hits().hits());

或者创建BoolQuery.Builder,以便进行业务判断是否增加查询条件

 List<FieldValue> fieldValues = new ArrayList<>();fieldValues.add(FieldValue.of(10));fieldValues.add(FieldValue.of(100));BoolQuery.Builder boolQuery = new BoolQuery.Builder();boolQuery.must(t->t.terms(v->v.field("label").terms(term->term.value(fieldValues))));boolQuery.must(t->t.match(f->f.field("name").query("旺仔")));SearchResponse<Object> search = elasticsearchClient.search(builder -> builder.index("my_test_index").query(q->q.bool(boolQuery.build())),Object.class);

10:多字段查询-multiMatch

        //多字段查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q->q.multiMatch(qs->qs.query("蚊虫叮咬 辣眼睛").fields("name","des"))),Produce.class);System.err.println(response.hits().hits());

11:高亮显示

我们注意要设置前缀和后缀

        //高亮显示final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q -> q.match(v -> v.field("name").query("风油精"))).highlight(h -> h.preTags("<span>").postTags("<span>").fields("name", hf -> hf)),Produce.class);System.err.println(response.toString());

12:分页查询

我们使用match_all进行全部搜索的时候使用size关键字设置每一页的大小,使用from关键字设置页码
from的计算公式:(页码-1)*size

        //分页查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q->q.matchAll(v->v)).size(2).from(0),Produce.class);System.err.println(response.hits().hits());

13:排序

使用sort关键字指定需要进行排序的字段设置排序类型即可,我们这里会使用到SortOrder枚举类来进行指定排序方式

desc:降序
asc:升序

        //排序final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q->q.matchAll(v->v)).sort(builder1 -> builder1.field(f->f.field("price").order(SortOrder.Asc))),Produce.class);System.err.println(response.hits().hits());

14:指定字段查询

使用_source关键字在数组中设置需要展示的字段
值得注意的是在source方法中需要我们写filter去指定是include包含或是exclude去除xx字段

        //指定字段查询final SearchResponse<Produce> response = client.search(builder ->builder.index("produces").query(q->q.matchAll(v->v)).source(s->s.filter(v->v.includes("price","des"))),Produce.class);System.err.println(response.hits().hits());

15:聚合查询-求最大值

SearchResponse<Object> search = elasticsearchClient.search(builder ->builder.index("my_test_index").from(0).size(1).aggregations("aa", t ->t.max(f->f.field("type"))), Object.class);EsResult esResult = EsUtils.searchAnalysis(search);Aggregate aa = esResult.getAggregations().get("aa");LongTermsAggregate lterms = aa.lterms();Buckets<LongTermsBucket> buckets = lterms.buckets();List<LongTermsBucket> array = buckets.array();

16:桶聚合查询-劣势 group by

SearchResponse<JSONObject> search = elasticsearchClient.search(builder ->builder.index(EsIndexConstants.article_info).query(t->t.range(f->f.field("create_time").gte(JsonData.of(startDate)).lte(JsonData.of(endDate)))).from(0).size(1).aggregations("countValue", t ->t.terms(f -> f.field("ata_type.keyword"))), JSONObject.class);
Aggregate countValue = search .getAggregations().get("countValue");
List<StringTermsBucket> array = countValue.sterms().buckets().array();

相关文章:

Elasticsearch-06-Elasticsearch Java API Client

前言 简介 在 Elasticsearch7.15版本之后&#xff0c;Elasticsearch官方将它的高级客户端 RestHighLevelClient标记为弃用状态。同时推出了全新的 Java API客户端 Elasticsearch Java API Client&#xff0c;该客户端也将在 Elasticsearch8.0及以后版本中成为官方推荐使用的客…...

计算机网络第3章-运输层(2)

可靠数据传输原理 可靠数据传输依靠数据在一条可靠信道上进行传输。 TCP也正是依靠可靠信道进行传数据&#xff0c;从而数据不会被丢失。 而实现这种可靠数据传输服务是可靠数据传输协议的责任 构造可靠数据传输协议 1.经完全可靠信道的可靠数据传输&#xff1a;rdt1.0 在…...

【微信小程序】实现投票功能(附源码)

一、Vant Weapp介绍 Vant Weapp 是一个基于微信小程序的组件库&#xff0c;它提供了丰富的 UI 组件和交互功能&#xff0c;能够帮助开发者快速构建出现代化的小程序应用。Vant Weapp 的设计理念注重简洁、易用和高效&#xff0c;同时提供灵活的定制化选项&#xff0c;以满足开发…...

Pytorch入门实例的分解写法

数据集是受教育年限和收入,如下图 代码如下 import torch import numpy as np import matplotlib.pyplot as plt import pandas as pddata pd.read_csv(./Income.csv)X torch.from_numpy(data.Education.values.reshape(-1,1).astype(np.float32)) Y torch.from_numpy(data…...

Google单元测试sample分析(一)

本文开始从googletest提供的sample案例分析如何使用单元测试&#xff0c; 代码路径在googletest/googletest/samples/sample1.unittest.cc 本文件主要介绍EXPECT*相关宏使用 EXPECT_EQ 判断是否相等 EXPECT_TRUE 是否为True EXPECT_FALSE 是否为False TEST(FactorialTest, N…...

requests 实践

Requests 常用参数 method&#xff1a; 请求方式 get&#xff0c;或者 post&#xff0c;put&#xff0c;delete 等 url : 请求的 url 地址 接口文档标注的接口请求地址 params&#xff1a;请求数据中的链接&#xff0c;常见的一个 get 请求&#xff0c;请求参数都是在 url 地址…...

UI设计公司成长日记2:修身及持之以恒不断学习是要务

作者&#xff1a;蓝蓝设计 要做一个好的UI设计公司,不仅要在能力上设计能力一直&#xff08;十几年几十年&#xff09;保持优秀稳定的保持输出&#xff0c;以及心态的平和宽广。创始人对做公司要有信心&#xff0c;合伙人之间要同甘共苦&#xff0c;遵守规则&#xff0c;做好表…...

辅助驾驶功能开发-功能规范篇(23)-2-Mobileye NOP功能规范

5.2 状态机要求 5.2.1 NOP/HWP 状态机 NOP/HWP状态机如下所示: 下表总结了这些状态: 状态描述Passive不满足功能条件,功能无法控制车辆执行器。Standby满足功能条件。该功能不是由驾驶员激活的。功能不控制车辆执行器。Active - Main功能由驾驶员激活。功能是控制…...

React中如何提高组件的渲染效率

一、是什么 react 基于虚拟 DOM 和高效 Diff算法的完美配合&#xff0c;实现了对 DOM最小粒度的更新&#xff0c;大多数情况下&#xff0c;React对 DOM的渲染效率足以我们的业务日常 复杂业务场景下&#xff0c;性能问题依然会困扰我们。此时需要采取一些措施来提升运行性能&…...

springboot+mybatis3.5.2动态查询某一字段在某一段时间内的统计信息(折线图)

需求&#xff1a; 动态查询某一统计字段在一段时间内的统计折线图信息 controller层 ApiOperation(value "getStatisticDetail", notes "统计折线图")GetMapping("/detail")ResponseStatus(HttpStatus.OK)AccessLogAnnotation(ignoreRequestA…...

关于本地项目上传到gitee的详细流程

如何上传本地项目到Gitee的流程&#xff1a; 1.Gitee创建项目 2. 进入所在文件夹&#xff0c;右键点击Git Bash Here 3.配置用户名和邮箱 在gitee的官网找到命令&#xff0c;注意这里的用户名和邮箱一定要和你本地的Git相匹配&#xff0c;否则会出现问题。 解决方法如下&…...

MarkDown详细入门笔记

本帖整理了MarkDown的入门学习笔记~ 一.介绍 Markdown 是一种轻量级的「标记语言」&#xff0c;它的优点很多&#xff0c;目前也被越来越多的写作爱好者&#xff0c;撰稿者广泛使用。 诸如微信公众平台、CSDN博客、还有Typora中写文档的部分&#xff0c;均涉及到MD的功能~ 它…...

算法——贪心算法

贪心算法&#xff08;Greedy Algorithm&#xff09;是一种算法设计策略&#xff0c;通常用于解决组合优化问题&#xff0c;其核心思想是在每一步都选择当前状态下最优的解&#xff0c;而不考虑之后的步骤。贪心算法在每一步都做出局部最优选择&#xff0c;期望通过一系列局部最…...

102.linux5.15.198 编译 firefly-rk3399(1)

1. 平台&#xff1a; rk3399 firefly 2g16g 2. 内核&#xff1a;linux5.15.136 &#xff08;从内核镜像网站下载&#xff09; 3. 交叉编译工具 gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 4. 宿主机&#xff1a;ubuntu18.04 5. 需要的素材和资料&#xff…...

易点易动固定资产管理系统:多种盘点方式助力年终固定资产盘点

年末固定资产盘点是企业管理中一项重要而繁琐的任务。为了帮助企业高效完成年终固定资产盘点工作&#xff0c;易点易动固定资产管理系统提供了多种盘点方式。本文将详细介绍易点易动固定资产管理系统的多种盘点方式&#xff0c;展示如何借助该系统轻松完成年终固定资产盘点&…...

C# Winform编程(10)Chart图表控件

Chart控件 Chart控件Chart属性详述Chart属性设置图表样式属性数据样式属性图例样式图标区样式SeriesChartType类型 Chart控件鼠标滚轮事件特殊处理Series绑定数据演示代码鼠标滚轮缩放图表示例参考引用 Chart控件 Chart控件是微软自带的一种图形可视化组件&#xff0c;使用简单…...

群狼调研(长沙产品概念测试)|如何做新品上市满意度调研

新品上市满意度调研是一种重要的市场研究方法&#xff0c;它通过收集和分析消费者对新产品的态度、购买意愿和满意度等方面的数据&#xff0c;帮助企业了解消费者的需求和期望&#xff0c;发现新产品的问题和不足&#xff0c;从而为产品改进提供有力的数据支持。群狼调研&#…...

Lua与C++交互

文章目录 1、Lua和C交互2、基础练习2.1、加载Lua脚本并传递参数2.2、加载脚本到stable&#xff08;包&#xff09;2.3、Lua调用c语言接口2.4、Lua实现面向对象2.5、向脚本中注册c的类 1、Lua和C交互 1、lua和c交互机制是基于一个虚拟栈&#xff0c;C和lua之间的所有数据交互都通…...

Ubuntu安装pyenv,配置虚拟环境

文章目录 安装pyenvpyenv创建虚拟环境一般情况下创建虚拟环境的方法 安装pyenv 摘自&#xff1a;文章 pyenv可以管理不同的python版本 1、安装pyenv的依赖库 # 执行以下命令安装依赖库 # 更新源 sudo apt-get update # 更新软件 sudo apt-get upgradesudo apt-get install ma…...

【分布式技术专题】「分布式技术架构」MySQL数据同步到Elasticsearch之N种方案解析,实现高效数据同步

MySQL数据同步到Elasticsearch之N种方案解析&#xff0c;实现高效数据同步 前提介绍MySQL和ElasticSearch的同步双写优点缺点针对于缺点补充优化方案 MySQL和ElasticSearch的异步双写优点缺点 定时延时写入ElasticSearch数据库机制优点缺点 开源和成熟的数据迁移工具选型Logsta…...

什么是React中的高阶组件(Higher Order Component,HOC)?它的作用是什么?

聚沙成塔每天进步一点点 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 欢迎来到前端入门之旅&#xff01;感兴趣的可以订阅本专栏哦&#xff01;这个专栏是为那些对Web开发感兴趣、刚刚踏入前端领域的朋友们量身打造的。无论你是完全的新手还是有一些基础的开发…...

NEFU离散数学实验3-递推方程

相关概念 递推方程是指一种递归定义&#xff0c;它将问题拆分成更小的子问题&#xff0c;并使用这些子问题的解来计算原问题的解。离散数学中&#xff0c;递推方程通常用于描述数列、组合问题等。 以下是一些递推方程相关的概念和公式&#xff1a; 1. 递推公式&#xff1a;递推…...

如何为你的地图数据设置地图样式?

地图样式设置是GIS系统中非常重要的功能模块&#xff0c;水经微图Web版本最近对符号样式功能模块进行了升级。 你可以通过以下网址直接打开访问&#xff1a; https://map.wemapgis.com 现在我们为大家分享一下水经微图Web版中&#xff0c;如何为你标注的地图数据设置地图样式…...

解决visual studio Just-In-Time Debugger调试

解决visual studio Just-In-Time Debugger调试 网上流行很多方法&#xff0c;最后一直不行&#xff0c;其实有最简单的方法比较实用 方法一&#xff1a;把 C:\WINDOWS\system32\vsjitdebugger.exe,删除了&#xff0c;若怕出问题&#xff0c;可以把它改名或者做个rar文件暂时保留…...

Uservue 中 keep-alive 组件的作用

目录 前言 用法 代码 理解 keep-alive 是 Vue.js 中一个内置的组件&#xff0c;它能够将不活动的组件实例保存在内存中&#xff0c;防止其被销毁&#xff0c;以便在后续需要时能够快速重新渲染。这个功能在一些需要频繁切换但不希望每次都重新渲染的场景中非常有用&#xf…...

gitlab查看、修改用户和邮箱,gitlab生成密钥

查看用户、邮箱 git config user.name git config user.email 修改用户、邮箱 git config --global user.name “xxx” git config --global user.email “xxxxxx.com” 生成ssh密钥 ssh-keygen -t rsa -C “xxxxxx.com” 查看SSH秘钥 cat ~/.ssh/id_rsa.pub 将秘钥复制&…...

python操作MySQL、SQL注入问题、视图、触发器、事务、存储过程、函数、流程控制、索引(重点)

python操作MySQL(重要) SQL的由来&#xff1a; MySQL本身就是一款C/S架构&#xff0c;有服务端、有客户端&#xff0c;自身带了有客户端&#xff1a;mysql.exe python这门语言成为了MySQL的客户端(对于一个服务端来说&#xff0c;客户端可以有很多) 操作步骤&#xff1a; …...

这一年的资源

#线性代数 https://textbooks.math.gatech.edu/ila/one-to-one-onto.html行业规范https://xlinux.nist.gov/dads/https://www.dhs.gov/publications产业群链基金会 https://www.cncf.io/谷歌 https://opensource.google/projects网飞 高德纳 https://www.gartne…...

从【臀部监控】到【电脑监控软件】,企业如何在隐私权与管理权博弈中找到平衡

【臀部监控】 依稀记得在2021年初某个高科技产品的爆火&#xff0c;惹得各大媒体网站争相报道。 起因是一位杭州网友在论坛上发帖&#xff0c;不久前公司给员工发放了一批高科技坐垫。 这个坐垫能自动感应心跳、呼吸在内的诸多人体数据&#xff0c;还能提醒人保持正确坐姿以及…...

数据库简介和sqlite3安装

数据库就是存储数据的仓库&#xff0c;其本质是一个文件系统&#xff0c;数据按照特定的格式将数据存储起来&#xff0c;用户可以对数据库中的数据进行增加&#xff0c;修改&#xff0c;删除及查询操作。 严格意义上来说,"数据库"不能被称之为"数据库",而…...