当前位置: 首页 > 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;最终打包生成到指定的文件中。如下图所示&#…...

基于算法竞赛的c++编程(28)结构体的进阶应用

结构体的嵌套与复杂数据组织 在C中&#xff0c;结构体可以嵌套使用&#xff0c;形成更复杂的数据结构。例如&#xff0c;可以通过嵌套结构体描述多层级数据关系&#xff1a; struct Address {string city;string street;int zipCode; };struct Employee {string name;int id;…...

【根据当天日期输出明天的日期(需对闰年做判定)。】2022-5-15

缘由根据当天日期输出明天的日期(需对闰年做判定)。日期类型结构体如下&#xff1a; struct data{ int year; int month; int day;};-编程语言-CSDN问答 struct mdata{ int year; int month; int day; }mdata; int 天数(int year, int month) {switch (month){case 1: case 3:…...

从WWDC看苹果产品发展的规律

WWDC 是苹果公司一年一度面向全球开发者的盛会&#xff0c;其主题演讲展现了苹果在产品设计、技术路线、用户体验和生态系统构建上的核心理念与演进脉络。我们借助 ChatGPT Deep Research 工具&#xff0c;对过去十年 WWDC 主题演讲内容进行了系统化分析&#xff0c;形成了这份…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

c#开发AI模型对话

AI模型 前面已经介绍了一般AI模型本地部署&#xff0c;直接调用现成的模型数据。这里主要讲述讲接口集成到我们自己的程序中使用方式。 微软提供了ML.NET来开发和使用AI模型&#xff0c;但是目前国内可能使用不多&#xff0c;至少实践例子很少看见。开发训练模型就不介绍了&am…...

MySQL中【正则表达式】用法

MySQL 中正则表达式通过 REGEXP 或 RLIKE 操作符实现&#xff08;两者等价&#xff09;&#xff0c;用于在 WHERE 子句中进行复杂的字符串模式匹配。以下是核心用法和示例&#xff1a; 一、基础语法 SELECT column_name FROM table_name WHERE column_name REGEXP pattern; …...

DeepSeek 技术赋能无人农场协同作业:用 AI 重构农田管理 “神经网”

目录 一、引言二、DeepSeek 技术大揭秘2.1 核心架构解析2.2 关键技术剖析 三、智能农业无人农场协同作业现状3.1 发展现状概述3.2 协同作业模式介绍 四、DeepSeek 的 “农场奇妙游”4.1 数据处理与分析4.2 作物生长监测与预测4.3 病虫害防治4.4 农机协同作业调度 五、实际案例大…...

OPENCV形态学基础之二腐蚀

一.腐蚀的原理 (图1) 数学表达式&#xff1a;dst(x,y) erode(src(x,y)) min(x,y)src(xx,yy) 腐蚀也是图像形态学的基本功能之一&#xff0c;腐蚀跟膨胀属于反向操作&#xff0c;膨胀是把图像图像变大&#xff0c;而腐蚀就是把图像变小。腐蚀后的图像变小变暗淡。 腐蚀…...

HarmonyOS运动开发:如何用mpchart绘制运动配速图表

##鸿蒙核心技术##运动开发##Sensor Service Kit&#xff08;传感器服务&#xff09;# 前言 在运动类应用中&#xff0c;运动数据的可视化是提升用户体验的重要环节。通过直观的图表展示运动过程中的关键数据&#xff0c;如配速、距离、卡路里消耗等&#xff0c;用户可以更清晰…...

NXP S32K146 T-Box 携手 SD NAND(贴片式TF卡):驱动汽车智能革新的黄金组合

在汽车智能化的汹涌浪潮中&#xff0c;车辆不再仅仅是传统的交通工具&#xff0c;而是逐步演变为高度智能的移动终端。这一转变的核心支撑&#xff0c;来自于车内关键技术的深度融合与协同创新。车载远程信息处理盒&#xff08;T-Box&#xff09;方案&#xff1a;NXP S32K146 与…...