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

Elasticsearch8.8.0 SpringBoot实战操作各种案例(索引操作、聚合、复杂查询、嵌套等)

Elasticsearch8.8.0 全网最新版教程 从入门到精通 通俗易懂

配置项目

引入依赖

<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.16</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>8.8.0</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.12.3</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>

添加配置文件

application.yaml

spring:elasticsearch:rest:scheme: httpshost: localhostport: 9200username: elasticpassword: 123456crt: classpath:ca.crt

导入ca证书到项目中

从任意一个es容器中,拷贝证书到resources目录下

/usr/share/elasticsearch/config/certs/ca

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EXytUrDp-1691330960034)(media/16912196423122/16912204609393.jpg)]

添加配置

package com.lglbc.elasticsearch;import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.TransportUtils;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;import javax.net.ssl.SSLContext;
import java.io.IOException;/*** @Description TODO* @Author 关注公众号 “乐哥聊编程” 领取资料和源码 * @Date 2023/07/14 21:04*/
@Configuration
public class ElasticConfig {@Value("${spring.elasticsearch.rest.scheme}")private String scheme;@Value("${spring.elasticsearch.rest.host}")private String host;@Value("${spring.elasticsearch.rest.port}")private int port;@Value("${spring.elasticsearch.rest.crt}")private String crt;@Value("${spring.elasticsearch.rest.username}")private String username;@Value("${spring.elasticsearch.rest.password}")private String password;@Autowiredprivate ResourceLoader resourceLoader;@Beanpublic ElasticsearchClient elasticsearchClient() throws IOException {SSLContext sslContext = TransportUtils.sslContextFromHttpCaCrt(resourceLoader.getResource(crt).getFile());BasicCredentialsProvider credsProv = new BasicCredentialsProvider();credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));RestClient restClient = RestClient.builder(new HttpHost(host, port, scheme)).setHttpClientConfigCallback(hc -> hc.setSSLContext(sslContext).setDefaultCredentialsProvider(credsProv)).build();// Create the transport and the API clientElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());ElasticsearchClient client = new ElasticsearchClient(transport);return client;}
}

实战操作

创建mapping

    @Testpublic void testCreateMapping() throws IOException {PutMappingRequest mappingRequest = new PutMappingRequest.Builder().index("lglbc_java_demo").properties("order_no", builder ->builder.keyword(type -> type)).properties("order_time", builder ->builder.date(type -> type.format("yyyy-MM-dd HH:mm:ss"))).properties("good_info", type -> type.nested(nested -> nested.properties("good_price", builder ->builder.double_(subType -> subType)).properties("good_count", builder ->builder.integer(subType -> subType)).properties("good_name", builder ->builder.text(subType ->subType.fields("keyword", subTypeField -> subTypeField.keyword(subSubType -> subSubType)))))).properties("buyer", builder ->builder.keyword(type -> type)).properties("phone", builder ->builder.keyword(type -> type)).build();ElasticsearchIndicesClient indices = elasticsearchClient.indices();if (indices.exists(request -> request.index("lglbc_java_demo")).value()) {indices.delete(request -> request.index("lglbc_java_demo"));}indices.create(request -> request.index("lglbc_java_demo"));indices.putMapping(mappingRequest);}

创建文档

@Testpublic void testAddData() throws IOException {OrderInfo orderInfo = new OrderInfo("1001", new Date(), "李白", "13098762567");List<OrderInfo.GoodInfo> goodInfos = new ArrayList<>();goodInfos.add(new OrderInfo.GoodInfo("苹果笔记本", 30.5d, 30));goodInfos.add(new OrderInfo.GoodInfo("苹果手机", 20.5d, 10));orderInfo.setGoodInfo(goodInfos);IndexRequest<OrderInfo> request = IndexRequest.of(i -> i.index("lglbc_java_demo").id(orderInfo.getOrderNo()).document(orderInfo));OrderInfo orderInfo2 = new OrderInfo("1002", new Date(), "苏轼", "13098762367");List<OrderInfo.GoodInfo> goodInfos2 = new ArrayList<>();goodInfos2.add(new OrderInfo.GoodInfo("华为笔记本", 18.5d, 15));goodInfos2.add(new OrderInfo.GoodInfo("苹果手机", 20.5d, 10));orderInfo2.setGoodInfo(goodInfos2);IndexRequest<OrderInfo> request2 = IndexRequest.of(i -> i.index("lglbc_java_demo").id(orderInfo2.getOrderNo()).document(orderInfo2));elasticsearchClient.index(request);elasticsearchClient.index(request2);}

查询更新

    @Testpublic void testUpdateDataByQuery() throws IOException {UpdateByQueryRequest request = UpdateByQueryRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.term(term -> term.field("order_no").value("1001"))).script(script -> script.inline(inline -> inline.lang("painless").source("ctx._source['buyer'] = 'java 更新->乐哥聊编程'"))));elasticsearchClient.updateByQuery(request);}

全量更新

    @Testpublic void testUpdateData() throws IOException {OrderInfo orderInfo3 = new OrderInfo("1002", new Date(), "苏轼3", "13098762367");List<OrderInfo.GoodInfo> goodInfos3 = new ArrayList<>();goodInfos3.add(new OrderInfo.GoodInfo("华为笔记本", 18.5d, 15));goodInfos3.add(new OrderInfo.GoodInfo("苹果手机", 20.5d, 10));orderInfo3.setGoodInfo(goodInfos3);UpdateRequest request = UpdateRequest.of(i -> i.index("lglbc_java_demo").id(orderInfo3.getOrderNo()).doc(orderInfo3));elasticsearchClient.update(request, OrderInfo.class);}

删除数据

    @Testpublic void testDelete() throws IOException {DeleteRequest request = DeleteRequest.of(i -> i.index("lglbc_java_demo").id("1002"));elasticsearchClient.delete(request);}

批量操作(bulk)

    @Testpublic void testBulkOperation() throws IOException {testCreateMapping();BulkRequest.Builder br = new BulkRequest.Builder();List<OrderInfo> orders = getOrders();for (OrderInfo orderInfo : orders) {br.operations(op -> op.index(idx -> idx.index("lglbc_java_demo").document(orderInfo)));}elasticsearchClient.bulk(br.build());}

基本搜索

    @Testpublic void testBaseSearch() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.term(term -> term.field("order_no").value("1001"))));SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();List<OrderInfo> orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(JSONUtil.toJsonStr(orderInfos));}

复杂布尔搜索

    @Testpublic void testBoolSearch() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.bool(bool -> bool.filter(filterQuery -> filterQuery.term(term -> term.field("buyer").value("李白"))).must(must -> must.term(term -> term.field("order_no").value("1004"))))));SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();List<OrderInfo> orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(JSONUtil.toJsonStr(orderInfos));}

嵌套(nested)搜索

    @Testpublic void testNestedSearch() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.nested(nested -> nested.path("good_info").query(nestedQuery -> nestedQuery.bool(bool -> bool.must(must -> must.range(range -> range.field("good_info.good_count").gte(JsonData.of("16")))).must(must2 -> must2.range(range -> range.field("good_info.good_price").gte(JsonData.of("30")))))))));SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();List<OrderInfo> orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(JSONUtil.toJsonStr(orderInfos));}

分页查询

   @Testpublic void testBasePageSearch() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").from(0).size(2).query(query -> query.matchAll(matchAll -> matchAll)));SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();List<OrderInfo> orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(orderInfos.size());request = SearchRequest.of(i -> i.index("lglbc_java_demo").from(2).size(2).query(query -> query.matchAll(matchAll -> matchAll)));response = elasticsearchClient.search(request, OrderInfo.class);hits = response.hits().hits();orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(orderInfos.size());request = SearchRequest.of(i -> i.index("lglbc_java_demo").from(4).size(2).query(query -> query.matchAll(matchAll -> matchAll)));response = elasticsearchClient.search(request, OrderInfo.class);hits = response.hits().hits();orderInfos = new ArrayList<>();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}System.out.println(orderInfos.size());}

滚动分页查询

@Testpublic void testScrollPageSearch() throws IOException {String scrollId = null;while (true) {List<OrderInfo> orderInfos = new ArrayList<>();if (StringUtils.isBlank(scrollId)) {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").scroll(Time.of(time -> time.time("1m"))).size(2).query(query -> query.matchAll(matchAll -> matchAll)));SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}scrollId = response.scrollId();} else {String finalScrollId = scrollId;ScrollRequest request = ScrollRequest.of(i -> i.scroll(Time.of(time -> time.time("1m"))).scrollId(finalScrollId));ScrollResponse response = elasticsearchClient.scroll(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());}scrollId = response.scrollId();}if (CollectionUtil.isEmpty(orderInfos)) {break;}System.out.println(orderInfos.size());}}

After分页查询

@Testpublic void testAfterPageSearch() throws IOException {final List<FieldValue>[] sortValue = new List[]{new ArrayList<>()};while (true) {List<OrderInfo> orderInfos = new ArrayList<>();SearchRequest request = SearchRequest.of(i -> {SearchRequest.Builder sort1 = i.index("lglbc_java_demo").size(2).sort(Lists.list(SortOptions.of(sort -> sort.field(field -> field.field("order_no").order(SortOrder.Desc)))));if (CollectionUtil.isNotEmpty(sortValue[0])) {sort1.searchAfter(sortValue[0]);}return sort1.query(query -> query.matchAll(matchAll -> matchAll));});SearchResponse<OrderInfo> response = elasticsearchClient.search(request, OrderInfo.class);List<Hit<OrderInfo>> hits = response.hits().hits();for (Hit hit : hits) {orderInfos.add((OrderInfo) hit.source());sortValue[0] = hit.sort();}if (CollectionUtil.isEmpty(orderInfos)) {break;}System.out.println(orderInfos.size());}}

词条(terms)聚合

@Testpublic void testTermsAgg() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.matchAll(match->match)).aggregations("agg_term_buyer",agg->agg.dateHistogram(dateHistogram->dateHistogram.field("order_time").calendarInterval(CalendarInterval.Day))));SearchResponse<Void> search = elasticsearchClient.search(request, Void.class);Map<String, Aggregate> aggregations = search.aggregations();Aggregate aggregate = aggregations.get("agg_term_buyer");Buckets<StringTermsBucket> buckets = ((StringTermsAggregate) aggregate._get()).buckets();for (StringTermsBucket bucket : buckets.array()) {String key = bucket.key()._toJsonString();long l = bucket.docCount();System.out.println(key+":::"+l);}}

日期聚合

@Testpublic void testDateAgg() throws IOException {SearchRequest request = SearchRequest.of(i -> i.index("lglbc_java_demo").query(query -> query.matchAll(match->match)).aggregations("agg_date_buyer",agg->agg.dateHistogram(dateHistogram->dateHistogram.field("order_time").calendarInterval(CalendarInterval.Day))));SearchResponse<Void> search = elasticsearchClient.search(request, Void.class);Map<String, Aggregate> aggregations = search.aggregations();Aggregate aggregate = aggregations.get("agg_date_buyer");List<DateHistogramBucket> buckets = ((DateHistogramAggregate) aggregate._get()).buckets().array();System.out.println(aggregate);for (DateHistogramBucket bucket : buckets) {String key = bucket.keyAsString();long l = bucket.docCount();System.out.println(key+":::"+l);}}

相关文章:

Elasticsearch8.8.0 SpringBoot实战操作各种案例(索引操作、聚合、复杂查询、嵌套等)

Elasticsearch8.8.0 全网最新版教程 从入门到精通 通俗易懂 配置项目 引入依赖 <dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.16</version></dependency><dependency>&l…...

《MySQL高级篇》十五、其他数据库日志

文章目录 1. MySQL支持的日志1.1 日志类型1.2 日志的弊端 2. 慢查询日志(slow query log)3. 通用查询日志3.1 问题场景3.2 查看当前状态3.3 启动日志3.4 查看日志3.5 停止日志3.6 删除\刷新日志 4. 错误日志(error log)4.1 启动日志4.2 查看日志4.3 删除\刷新日志4.4 MySQL8.0新…...

【Linux】【预】配置虚拟机的桥接网卡+nfs

【Linux】【预】配置虚拟机的桥接网卡 1. 配置VM虚拟机的桥接网络2 配置Win10中的设置3.配置Linux中的IP4. 串口连接开发板&#xff0c;配置nfs5 修改网络文件6 验证nfs 是否成功总结 1. 配置VM虚拟机的桥接网络 右击设置&#xff0c;选择添加网络&#xff0c;按照如下顺序操作…...

【Android】Retrofit2和RxJava2新手快速上手

写这篇博客的目的 网上关于Retrofit2和RxJava2的博客特别多&#xff0c;但是内容特别复杂&#xff0c;一上来就讲解很高级的用法 其实我们没必要像高考做题家一样&#xff0c;把每个API都背的滚瓜烂熟 熟悉基本用法&#xff0c;高阶用法需要的时候再逐个了解就行了 因为博客…...

1.4 Nacos注册中心

目录 什么是Nacos Nacos下载和安装 下载和安装 启动 Nacos服务注册与发现 Nacos的服务分级存储模型 什么是分级存储模型 配置实例集群 配置同集群优先的负载均衡 权重配置 点击编辑按钮 配置所需的权重 环境隔离 创建namespace 什么是Nacos Nacoshttps://nacos.i…...

AOJ 2200 Mr. Rito Post Office 最短路径+动态规划+谨慎+思维

我写了好多注释&#xff0c;一看就能看懂&#xff0c;这个题目我想了6&#xff0c;7个小时&#xff0c;一开始忽略了船的位置和要把船安置的位置一致的情况&#xff0c;补上就对了。 #include <iostream> using namespace std; int inf 0x3f3f3f3f, num[1007], dp[1007…...

红米电视 ADB 安装 app 报错 failed to authenticate xxx:5555

开启电视开发者模式&#xff0c;允许安装未知来源应用及开启 ADB 调试电脑端下载 adb 工具 点击下载同一局域网的电脑使用 adb 工具连接&#xff08;提前查看电视 IP&#xff09;D:\adb>adb connect 192.168.1.7 * daemon not running; starting now at tcp:5037 * daemon s…...

Linux 下设置开机自启动的方法

文章目录 事先准备对于普通的 Linux对于 RedHat Enterprise Linux 9 笔者的运行环境&#xff1a; 设置成功过的 Linux&#xff1a; RedHat Enterprise Linux 9 x86_64 CentOS 8 x86_64 事先准备 进行这个教程之前&#xff0c;必须要先安装好一个 Linux 操作系统。这个 Linux…...

MySQL常见问题处理(三)

MySQL 常见问题解决 夕阳留恋的不是黄昏&#xff0c;而是朝阳 上一章简单介绍了MySQL数据库安装(二), 如果没有看过, 请观看上一章 一. root 用户密码忘记&#xff0c;进行重置操作 复制内容来源链接: https://blog.csdn.net/weixin_48927364/article/details/123556927 一.…...

maven中常见问题

文章目录 一、配置项提示二、父子打包三、打包之后不显示target四、自定义打包之后的jar包名称五、整个项目打包5.1、父项目管理插件和微服务打包 一、配置项提示 SpringBoot中提示错误信息 表示的是SpringBoot中的注释提示没有配置&#xff01;那么可以来使用一下springboot官…...

vue2中bus的使用

说明&#xff1a;为了解决组件间的通信&#xff0c;也就是组件与组件间的数据传递(它们之间毫无关系)&#xff1b; 这里以组件1传递数据到组件2为例 1.首先新建一个Bus.js文件 import Vue from vue const Bus new Vue() export default Bus 2.在组件1中引用 传递数据 imp…...

实证研究在机器学习中的应用

实证研究是一种基于实际数据和事实的科学研究方法&#xff0c;目的是通过观察、测量、分析和解释数据来验证或否定某个假设、理论或研究问题。这种研究方法通常用于社会科学、自然科学和医学等领域。以下是实证研究的详细解释&#xff1a; 研究目标&#xff1a;实证研究旨在通过…...

IO进程线程day8(2023.8.6)

一、Xmind整理&#xff1a; 管道的原理&#xff1a; 有名管道的特点&#xff1a; 信号的原理&#xff1a; 二、课上练习&#xff1a; 练习1&#xff1a;pipe 功能&#xff1a;创建一个无名管道&#xff0c;同时打开无名管道的读写端 原型&#xff1a; #include <unist…...

【5G NR】逻辑信道、传输信道和物理信道的映射关系

博主未授权任何人或组织机构转载博主任何原创文章&#xff0c;感谢各位对原创的支持&#xff01; 博主链接 本人就职于国际知名终端厂商&#xff0c;负责modem芯片研发。 在5G早期负责终端数据业务层、核心网相关的开发工作&#xff0c;目前牵头6G算力网络技术标准研究。 博客…...

tmux基础教程

tmux基础教程 Mac安装 brew install tmuxubuntu安装 sudo apt-get install tmux入门使用 会话 (Session) Ctrlb d: 分离当前会话。Ctrlb s: 列出所有会话。Ctrlb $: 重命名当前会话。 窗口&#xff08;Window&#xff09; Ctrlb c: 创建一个新窗口, 状态栏会显示多个窗…...

项目实战 — 消息队列(4){消息持久化}

目录 一、消息存储格式设计 &#x1f345; 1、queue_data.txt&#xff1a;保存消息的内容 &#x1f345; 2、queue_stat.txt&#xff1a;保存消息的统计信息 二、消息序列化 三、自定义异常类 四、创建MessageFileManger类 &#x1f345; 1、约定消息文件所在的目录和文件名…...

AI编程工具Copilot与Codeium的实测对比

csdn原创谢绝转载 简介 现在没有AI编程工具&#xff0c;效率会打一个折扣&#xff0c;如果还没有&#xff0c;赶紧装起来&#xff0e; GitHub Copilot是OpenAi与github等共同开发的的AI辅助编程工具&#xff0c;基于ChatGPT驱动&#xff0c;功能强大&#xff0c;这个没人怀疑…...

webpack基础知识六:说说webpack的热更新是如何做到的?原理是什么?

一、是什么 HMR全称 Hot Module Replacement&#xff0c;可以理解为模块热替换&#xff0c;指在应用程序运行过程中&#xff0c;替换、添加、删除模块&#xff0c;而无需重新刷新整个应用 例如&#xff0c;我们在应用运行过程中修改了某个模块&#xff0c;通过自动刷新会导致…...

Linux从安装到实战 常用命令 Bash常用功能 用户和组管理

1.0初识Linux 1.1虚拟机介绍 1.2VMware Workstation虚拟化软件 下载CentOS; 1.3远程链接Linux系统 &FinalShell 链接finalshell半天没连接进去 他说ip adress 看IP地址是在虚拟机上 win11主机是 终端输入&#xff1a; ifconfig VMware虚拟机的设置 & ssh连接_snge…...

webpack基础知识三:说说webpack中常见的Loader?解决了什么问题?

一、是什么 loader 用于对模块的"源代码"进行转换&#xff0c;在 import 或"加载"模块时预处理文件 webpack做的事情&#xff0c;仅仅是分析出各种模块的依赖关系&#xff0c;然后形成资源列表&#xff0c;最终打包生成到指定的文件中。如下图所示&#…...

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

基于服务器使用 apt 安装、配置 Nginx

&#x1f9fe; 一、查看可安装的 Nginx 版本 首先&#xff0c;你可以运行以下命令查看可用版本&#xff1a; apt-cache madison nginx-core输出示例&#xff1a; nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

在四层代理中还原真实客户端ngx_stream_realip_module

一、模块原理与价值 PROXY Protocol 回溯 第三方负载均衡&#xff08;如 HAProxy、AWS NLB、阿里 SLB&#xff09;发起上游连接时&#xff0c;将真实客户端 IP/Port 写入 PROXY Protocol v1/v2 头。Stream 层接收到头部后&#xff0c;ngx_stream_realip_module 从中提取原始信息…...

江苏艾立泰跨国资源接力:废料变黄金的绿色供应链革命

在华东塑料包装行业面临限塑令深度调整的背景下&#xff0c;江苏艾立泰以一场跨国资源接力的创新实践&#xff0c;重新定义了绿色供应链的边界。 跨国回收网络&#xff1a;废料变黄金的全球棋局 艾立泰在欧洲、东南亚建立再生塑料回收点&#xff0c;将海外废弃包装箱通过标准…...

TRS收益互换:跨境资本流动的金融创新工具与系统化解决方案

一、TRS收益互换的本质与业务逻辑 &#xff08;一&#xff09;概念解析 TRS&#xff08;Total Return Swap&#xff09;收益互换是一种金融衍生工具&#xff0c;指交易双方约定在未来一定期限内&#xff0c;基于特定资产或指数的表现进行现金流交换的协议。其核心特征包括&am…...

Module Federation 和 Native Federation 的比较

前言 Module Federation 是 Webpack 5 引入的微前端架构方案&#xff0c;允许不同独立构建的应用在运行时动态共享模块。 Native Federation 是 Angular 官方基于 Module Federation 理念实现的专为 Angular 优化的微前端方案。 概念解析 Module Federation (模块联邦) Modul…...

【HTML-16】深入理解HTML中的块元素与行内元素

HTML元素根据其显示特性可以分为两大类&#xff1a;块元素(Block-level Elements)和行内元素(Inline Elements)。理解这两者的区别对于构建良好的网页布局至关重要。本文将全面解析这两种元素的特性、区别以及实际应用场景。 1. 块元素(Block-level Elements) 1.1 基本特性 …...

【RockeMQ】第2节|RocketMQ快速实战以及核⼼概念详解(二)

升级Dledger高可用集群 一、主从架构的不足与Dledger的定位 主从架构缺陷 数据备份依赖Slave节点&#xff0c;但无自动故障转移能力&#xff0c;Master宕机后需人工切换&#xff0c;期间消息可能无法读取。Slave仅存储数据&#xff0c;无法主动升级为Master响应请求&#xff…...

在web-view 加载的本地及远程HTML中调用uniapp的API及网页和vue页面是如何通讯的?

uni-app 中 Web-view 与 Vue 页面的通讯机制详解 一、Web-view 简介 Web-view 是 uni-app 提供的一个重要组件&#xff0c;用于在原生应用中加载 HTML 页面&#xff1a; 支持加载本地 HTML 文件支持加载远程 HTML 页面实现 Web 与原生的双向通讯可用于嵌入第三方网页或 H5 应…...