当前位置: 首页 > 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…...

云原生核心技术 (7/12): K8s 核心概念白话解读(上):Pod 和 Deployment 究竟是什么?

大家好&#xff0c;欢迎来到《云原生核心技术》系列的第七篇&#xff01; 在上一篇&#xff0c;我们成功地使用 Minikube 或 kind 在自己的电脑上搭建起了一个迷你但功能完备的 Kubernetes 集群。现在&#xff0c;我们就像一个拥有了一块崭新数字土地的农场主&#xff0c;是时…...

iPhone密码忘记了办?iPhoneUnlocker,iPhone解锁工具Aiseesoft iPhone Unlocker 高级注册版​分享

平时用 iPhone 的时候&#xff0c;难免会碰到解锁的麻烦事。比如密码忘了、人脸识别 / 指纹识别突然不灵&#xff0c;或者买了二手 iPhone 却被原来的 iCloud 账号锁住&#xff0c;这时候就需要靠谱的解锁工具来帮忙了。Aiseesoft iPhone Unlocker 就是专门解决这些问题的软件&…...

【快手拥抱开源】通过快手团队开源的 KwaiCoder-AutoThink-preview 解锁大语言模型的潜力

引言&#xff1a; 在人工智能快速发展的浪潮中&#xff0c;快手Kwaipilot团队推出的 KwaiCoder-AutoThink-preview 具有里程碑意义——这是首个公开的AutoThink大语言模型&#xff08;LLM&#xff09;。该模型代表着该领域的重大突破&#xff0c;通过独特方式融合思考与非思考…...

鱼香ros docker配置镜像报错:https://registry-1.docker.io/v2/

使用鱼香ros一件安装docker时的https://registry-1.docker.io/v2/问题 一键安装指令 wget http://fishros.com/install -O fishros && . fishros出现问题&#xff1a;docker pull 失败 网络不同&#xff0c;需要使用镜像源 按照如下步骤操作 sudo vi /etc/docker/dae…...

今日科技热点速览

&#x1f525; 今日科技热点速览 &#x1f3ae; 任天堂Switch 2 正式发售 任天堂新一代游戏主机 Switch 2 今日正式上线发售&#xff0c;主打更强图形性能与沉浸式体验&#xff0c;支持多模态交互&#xff0c;受到全球玩家热捧 。 &#x1f916; 人工智能持续突破 DeepSeek-R1&…...

2023赣州旅游投资集团

单选题 1.“不登高山&#xff0c;不知天之高也&#xff1b;不临深溪&#xff0c;不知地之厚也。”这句话说明_____。 A、人的意识具有创造性 B、人的认识是独立于实践之外的 C、实践在认识过程中具有决定作用 D、人的一切知识都是从直接经验中获得的 参考答案: C 本题解…...

Fabric V2.5 通用溯源系统——增加图片上传与下载功能

fabric-trace项目在发布一年后,部署量已突破1000次,为支持更多场景,现新增支持图片信息上链,本文对图片上传、下载功能代码进行梳理,包含智能合约、后端、前端部分。 一、智能合约修改 为了增加图片信息上链溯源,需要对底层数据结构进行修改,在此对智能合约中的农产品数…...

论文笔记——相干体技术在裂缝预测中的应用研究

目录 相关地震知识补充地震数据的认识地震几何属性 相干体算法定义基本原理第一代相干体技术&#xff1a;基于互相关的相干体技术&#xff08;Correlation&#xff09;第二代相干体技术&#xff1a;基于相似的相干体技术&#xff08;Semblance&#xff09;基于多道相似的相干体…...

Linux 内存管理实战精讲:核心原理与面试常考点全解析

Linux 内存管理实战精讲&#xff1a;核心原理与面试常考点全解析 Linux 内核内存管理是系统设计中最复杂但也最核心的模块之一。它不仅支撑着虚拟内存机制、物理内存分配、进程隔离与资源复用&#xff0c;还直接决定系统运行的性能与稳定性。无论你是嵌入式开发者、内核调试工…...

并发编程 - go版

1.并发编程基础概念 进程和线程 A. 进程是程序在操作系统中的一次执行过程&#xff0c;系统进行资源分配和调度的一个独立单位。B. 线程是进程的一个执行实体,是CPU调度和分派的基本单位,它是比进程更小的能独立运行的基本单位。C.一个进程可以创建和撤销多个线程;同一个进程中…...