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

ES8的Java API client 8.0 简单示例操作 Elasticsearch

1.加入依赖

      <dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>8.12.2</version></dependency>

2.配置类

@Slf4j
@Configuration
public class ElasticSearchConfig {@Value("${elasticsearch.hosts}")private String hosts;@Value("${elasticsearch.port}")private int port;@Value("${elasticsearch.username}")private String username;@Value("${elasticsearch.password}")private String password;@Value("${elasticsearch.apikey:''}")private String apikey;/*** 单节点没密码连接** @return*/@Beanpublic ElasticsearchClient elasticsearchClient() {String[] servers = hosts.split(",");int len = servers.length;if (0 == len) {log.error("ElasticsearchClient 配置错误!");}ElasticsearchTransport transport = null;// 不是集群时if (1 == len) {// 无账号、密码if (StringUtils.isEmpty(username) && StringUtils.isEmpty(password)) {RestClient client = RestClient.builder(new HttpHost(servers[0], port, "http")).setHttpClientConfigCallback(httpClientBuilder->httpClientBuilder.setDefaultHeaders(Collections.singletonList(new BasicHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()))).addInterceptorLast((HttpResponseInterceptor) (response, context)-> response.addHeader("X-Elastic-Product", "Elasticsearch"))).build();transport = new RestClientTransport(client, new JacksonJsonpMapper());} else {// 账号密码的配置final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));// 自签证书的设置,并且还包含了账号密码RestClientBuilder.HttpClientConfigCallback callback = httpAsyncClientBuilder -> httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider).addInterceptorLast((HttpResponseInterceptor)(response, context) ->response.addHeader("X-Elastic-Product", "Elasticsearch"));RestClient client = RestClient.builder(new HttpHost(servers[0], port, "http")).setHttpClientConfigCallback(callback).build();transport = new RestClientTransport(client, new JacksonJsonpMapper());}} else {// 集群时无账号、密码if (StringUtils.isEmpty(username) && StringUtils.isEmpty(password)) {transport = getElasticsearchTransport(toHttpHost());} else {transport = getElasticsearchTransport(username, password, toHttpHost());}}return new ElasticsearchClient(transport);}private HttpHost[] toHttpHost() {if (hosts.split(",").length == 0) {throw new RuntimeException("invalid elasticsearch configuration");}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;}private static ElasticsearchTransport getElasticsearchTransport(String username, String password, HttpHost... hosts) {// 账号密码的配置final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));// 自签证书的设置,并且还包含了账号密码RestClientBuilder.HttpClientConfigCallback callback = httpAsyncClientBuilder -> httpAsyncClientBuilder.setSSLContext(buildSSLContext()).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setDefaultCredentialsProvider(credentialsProvider).setDefaultHeaders(Stream.of(new BasicHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString())).collect(toList())).addInterceptorLast((HttpResponseInterceptor)(response, context) ->response.addHeader("X-Elastic-Product", "Elasticsearch")).addInterceptorLast((HttpResponseInterceptor) (response, context)-> response.addHeader("X-Elastic-Product", "Elasticsearch"));// 用builder创建RestClient对象RestClient client = RestClient.builder(hosts).setHttpClientConfigCallback(callback).build();return new RestClientTransport(client, new JacksonJsonpMapper());}private static ElasticsearchTransport getElasticsearchTransport(HttpHost... hosts) {// 用builder创建RestClient对象RestClient client = RestClient.builder(hosts).build();return new RestClientTransport(client, new JacksonJsonpMapper());}private static SSLContext buildSSLContext() {ClassPathResource resource = new ClassPathResource("es01.crt");SSLContext sslContext = null;try {CertificateFactory factory = CertificateFactory.getInstance("X.509");Certificate trustedCa;try (InputStream is = resource.getInputStream()) {trustedCa = factory.generateCertificate(is);}KeyStore trustStore = KeyStore.getInstance("pkcs12");trustStore.load(null, null);trustStore.setCertificateEntry("ca", trustedCa);SSLContextBuilder sslContextBuilder = SSLContexts.custom().loadTrustMaterial(trustStore, null);sslContext = sslContextBuilder.build();} catch (CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException |KeyManagementException e) {log.error("ES连接认证失败", e);}return sslContext;}
}

3.相关api

前提:

注入ElasticsearchClient

@Autowired
private ElasticsearchClient client;

3.1 创建索引

 public void createIndex() throws IOException {ElasticsearchIndicesClient indices = client.indices();//是否存在//1.lambdaboolean isExit = indices.exists(req -> req.index("ttt")).value();//2.builder,ofExistsRequest existsRequestOf = ExistsRequest.of(req -> req.index("ttt"));ExistsRequest existsRequest = new ExistsRequest.Builder().index("ttt").build();boolean builderExist = indices.exists(existsRequest).value();if (isExit){log.info("已经存在ttt");}else {//1.lambdaboolean isSuccess = indices.create(req -> req.index("ttt")).acknowledged();//2.builder,ofCreateIndexRequest createIndexRequestOf = CreateIndexRequest.of(req -> req.index("ttt"));CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index("ttt").build();boolean buildIsSuccess = indices.create(createIndexRequest).acknowledged();if (isSuccess){log.info("创建成功");}else {log.info("创建失败");}}}

3.2 删除索引

public void deleteIndex() throws IOException {//1.lambdaboolean isSuccess = client.indices().delete(req -> req.index("ttt")).acknowledged();//2.builder,ofDeleteIndexRequest deleteRequestOf = DeleteIndexRequest.of(req -> req.index("ttt"));DeleteIndexRequest deleteRequest = new DeleteIndexRequest.Builder().index("ttt").build();boolean buildDeleteRequest = client.indices().delete(deleteRequest).acknowledged();}

3.3查询索引

 public void queryIndex() throws IOException {//1.lambda//查询单个Map<String, IndexState> tttIndex = client.indices().get(req -> req.index("ttt")).result();//查询索引Set<String> all = client.indices().get(req -> req.index("*")).result().keySet();//2.builderGetIndexRequest getIndexRequestOf = GetIndexRequest.of(req -> req.index("ttt"));GetIndexRequest getIndexRequest = new GetIndexRequest.Builder().index("ttt").build();Map<String, IndexState> result = client.indices().get(getIndexRequest).result();}

3.4 插入文档

 public void addDoc() throws IOException {Goods goods = new Goods("3212334","华为mate60", 9999.0);//1.lambdaclient.index(i->i.index("goods").id(goods.getSku()).document(goods));//2.builder-ofIndexRequest<Goods> addIndexRequestOf = IndexRequest.of(t -> t.id(goods.getSku()).document(goods).index("goods"));IndexRequest<Goods> addIndexRequest = new IndexRequest<>.Builder().index("goods").id(goods.getSku()).document(goods).build();IndexResponse index = client.index(addIndexRequest);}

3.5 批量插入文档

public void addBatchDoc() throws IOException {List<Goods> goodsList = List.of(new Goods("1","手机",999.0));BulkRequest.Builder br = new BulkRequest.Builder();for (Goods goods : goodsList) {br.operations(op->op.index(idx->idx.index("goods").id(goods.getSku()).document(goods)));}BulkResponse result = client.bulk(br.build());// Log errors, if anyif (result.errors()) {log.error("Bulk had errors");for (BulkResponseItem item: result.items()) {if (item.error() != null) {log.error(item.error().reason());}}}}

3.6查询文档

public void queryDoc() throws IOException {//1.lambdaGetResponse<Goods> response = client.get(g ->  g.index("goods").id("00000"), Goods.class);//2.builder,ofGetRequest request = GetRequest.of(g -> g.index("goods").id("00000"));GetRequest ofRequest = new GetRequest.Builder().index("goods").id("00000").build();GetResponse<Goods> response1 = client.get(request, Goods.class);if (response.found()){Goods source = response.source();System.out.println(source);}}

3.7修改文档

 public void updateDoc() throws IOException {//全量Goods goods = new Goods("1","2",3.0);UpdateResponse<Goods> update = client.update(u -> u.doc(goods).id(goods.getSku()), Goods.class);//ofUpdateRequest<Object, Object> of = UpdateRequest.of(u -> u.id(goods.getSku()).doc(goods));UpdateResponse<Object> update1 = client.update(of, Goods.class);}

3.8删除文档

   */public void deleteDoc() throws IOException {DeleteResponse goods = client.delete(d -> d.index("goods").id("0000"));//ofDeleteRequest deleteRequest = DeleteRequest.of(d -> d.index("goods").id("0000"));client.delete(deleteRequest);}

3.9 DSL 匹配查询

public void query() throws IOException {String text = "华为mate60";SearchResponse<Goods> response = client.search(s -> s.index("goods").query(q -> q.match(m -> m.field("name").query(text))), Goods.class);//ofSearchRequest request = SearchRequest.of(s -> s.index("goods").query(q -> q.match(m ->m.field("").field(""))));SearchResponse<Goods> search = client.search(request, Goods.class);//结果//总数TotalHits total = response.hits().total();assert total != null;boolean isExactResult = total.relation() == TotalHitsRelation.Eq;if (isExactResult) {log.info("找到 " + total.value() + " 个结果");} else {log.info("找到超过 " + total.value() + " 个结果");}List<Hit<Goods>> hits = response.hits().hits();for (Hit<Goods> hit : hits) {Goods goods = hit.source();System.out.println(goods);}}

3.10 多精确terms

public void terms(){List<FieldValue> v = new ArrayList<>();FieldValue tag2 = FieldValue.of("tag2");FieldValue tag1 = FieldValue.of("tag1");v.add(tag1);v.add(tag2);TermsQuery tags = TermsQuery.of(t -> t.field("tags").terms(tm -> tm.value(v)));SearchRequest of = SearchRequest.of(s -> s.index("goods").query(q -> q.bool(b -> b.must(m -> m.terms(tags)).should(sh -> sh.match(ma -> ma.field("").query(""))))).from(0).size(10));}

3.11 布尔查询

@Slf4j
@Service
public class EsTest {@Autowiredprivate ElasticsearchClient client;/*** bool*/public void boolQuery() throws IOException {Map<String, HighlightField> map = new HashMap<>();map.put("title", HighlightField.of(hf -> hf.preTags("<em>").postTags("<em/>")));map.put("description", HighlightField.of(hf -> hf.preTags("<em>").postTags("<em/>").numberOfFragments(4).fragmentSize(50)));//numberOfFragments(4),表示将字段分割为最多4个片段,并设置 fragmentSize(50),表示每个片段的大小为50个字符。Highlight highlight = Highlight.of(h -> h.type(HighlighterType.Unified).fields(map).fragmentSize(50)//设置默认的高亮片段大小为50个字符,如果字段没有单独设置,则使用此默认值。.numberOfFragments(5)//设置每个字段的最大高亮片段数为5个。);String text = "华为mate60";SearchResponse<Goods> search = client.search(s -> s.index("goods").query(q -> q.bool(b -> b.must(m -> m.term(t -> t.field("品牌").value("华为"))).should(sd -> sd.match(mh -> mh.field("name").query("mate60"))))).from(0).size(10).highlight(highlight), Goods.class);//ofSearchRequest of = SearchRequest.of(s -> s.index("goods").query(q -> q.bool(b -> b.must(m -> m.term(t -> t.field("品牌").value("华为"))).should(sh -> sh.match(ma -> ma.field("").query(""))))).from(0).size(10).highlight(highlight));SearchResponse<Goods> response = client.search(of, Goods.class);List<Hit<Goods>> hits = response.hits().hits();for (Hit<Goods> hit : hits) {Goods goods = hit.source();if (goods == null){continue;}Map<String, List<String>> highlightList = hit.highlight();highlightList.forEach((key, Value)->{if (Objects.equals(key,goods.getName())){//存入}else {//无高亮}});System.out.println(goods);}}}

3.12构建排序

/*** 构建排序*/private List<SortOptions> buildSort(SearchDTO dto) {if (dto.getTimeSort() != null){SortOptions sortOptions ;if (dto.getTimeSort() == 0){sortOptions = SortOptions.of(s -> s.field(FieldSort.of(f -> f.field(SearchConstants.TIMESTAMP).order(SortOrder.Asc))));}else {sortOptions = SortOptions.of(s -> s.field(FieldSort.of(f -> f.field(SearchConstants.TIMESTAMP).order(SortOrder.Desc))));}return List.of(sortOptions);}else {return Collections.emptyList();}}

...........

相关文章:

ES8的Java API client 8.0 简单示例操作 Elasticsearch

1.加入依赖 <dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>8.12.2</version></dependency>2.配置类 Slf4j Configuration public class ElasticSearchConfig {Valu…...

多线程CompletableFuture

最近发现同事整理了一个不错的关于CompletableFuture的文档&#xff0c;在这里记录一下&#xff0c;方便以后工作备用 CompletableFuture future CompletableFuture.supplyAsync(() -> {return "开新线程异步执行"; })result future.get(); // 线程阻塞等待结果…...

AR传送门+特定区域显示内容+放大镜 效果着色器使用

AR传送门特定区域显示内容放大镜 效果 关键词&#xff1a;Portal Mask 1、教程链接&#xff1a; AR 传送门教程 Unity - Portal Mask Implementation - Part 4_哔哩哔哩_bilibili 应用案例效果&#xff1a; 2、案例下载地址&#xff1a;使用unity 2021.3.33f1 obi 工具…...

设置Hadoop守护进程的JVM参数

一般情况下我们不去动守护进程的JVM&#xff0c;这里的守护进程说的是NameNode、DataNode等Hadoop服务自己本身的进程。但是有一些特殊情况下需要限制&#xff0c;比如工作中虽然集群中资源队列会有10%左右的预留空余&#xff0c;不过这是整个集群队列的限制&#xff0c;对于Da…...

可视化大屏

可视化大屏 是一种利用计算机图形学技术&#xff0c;将复杂的数据和信息转换为直观的可视化图形&#xff0c;以呈现数据信息的工具。它不仅在电影中常见&#xff0c;而且已经实实在在地被应用在商业、金融、制造等各个行业的业务场景中&#xff0c;成为大数据分析和展示的重要工…...

pytest框架

pytest测试框架 单元测试框架定义&#xff1a;针对软件开发最小的单元&#xff08;函数&#xff0c;方法&#xff09;进行正确性位置测试 单元测试框架&#xff1a;java&#xff08;junit&#xff0c;testing&#xff09;python&#xff08;unittest&#xff0c;pytest&#…...

基于大数据的亚健康人群数据分析及可视化系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码 精品专栏&#xff1a;Java精选实战项目…...

黄金短线交易策略:波动中的高效盈利之法

今日&#xff0c;亚市盘初&#xff0c;现货黄金就高位震荡。在昨日金价再度冲高&#xff0c;一度刷新历史高点至2685.49美元&#xff0c;收报2672.25美元。其中主要原因是美国公布了最新的核心PCE&#xff08;个人消费支出&#xff09;物价指数和初请失业金人数等经济数据&…...

西陆家政系统V1.0.1

微信小程序开发的西陆家政服务管理系统小程序 V1.0.1bug修复优化 1.修复首页轮播不能自动轮播问题;2.修复订单详情价格显示问题;3.修复在开放城市模式下,其他城市可以下单问题;4.修复个人二维码跳转小程序路径异常问题;5.修复小程序编辑我的地址选择定位后不刷新问题&#xf…...

时间安全精细化管理平台/iapp/mobile/facereg/facereg.html接口存在未授权访问漏洞

漏洞描述 登录--时间&安全精细化管理平台/iapp/mobile/facereg/facereg.html接口存在未授权访问漏洞&#xff0c;黑客可以未授权等级员工信息对平台造成影响 FOFA&#xff1a; body"登录--时间&amp;安全精细化管理平台" 漏洞复现 IP/iapp/mobile/facereg…...

自动化测试实例:Web登录功能性测试(无验证码)

&#x1f345; 点击文末小卡片 &#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 一、什么是自动化测试 把人为驱动的测试行为转化为机器执行的一种过程称为自动化测试。(来自百度百科)本质上来说&#xff0c;自动化测试对比起手工测试除了需要…...

【算法篇】二叉树类(3)(笔记)

目录 一、Leetcode 题目 1. 二叉树的最近公共祖先 2. 二叉搜索树的最近公共祖先 &#xff08;1&#xff09;递归法 &#xff08;2&#xff09;迭代法 3. 二叉搜索树中的插入操作 &#xff08;1&#xff09;递归法 &#xff08;2&#xff09;迭代法 4. 删除二叉搜索树中…...

基于php的律所管理系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码 精品专栏&#xff1a;Java精选实战项目…...

MySQL 之索引详解

想象一下&#xff0c;你正在图书馆寻找一本关于 MySQL 索引的书。图书馆里有成千上万本书&#xff0c;但没有目录。你只能一排一排、一本一本地找&#xff0c;直到找到你想要的书。这将会花费大量的时间&#xff01;数据库索引就像图书馆的目录一样&#xff0c;可以帮助数据库系…...

C#测试调用FreeSpire.PDFViewer浏览PDF文件

Free Spire.PDFViewer是商业版Spire.PDFViewer的社区版本&#xff0c;支持以控件形式打开并查看PDf文件&#xff0c;但由于是免费版本&#xff0c;存在使用限制&#xff0c;打开的PDF文档只显示前10页内容。如果日常操作的pdf文件都不超过10页&#xff0c;可以考虑使用Free Spi…...

又一挣钱副业:AI生成影视解说,半个月涨粉变现3.5W+!

这两年大家都在感叹生活不易&#xff0c;然而我想说的是&#xff0c;机会还是有的&#xff0c;但问题不在于有没有&#xff0c;而在于你是否能够认准机会&#xff0c;然后抓住它。 接触过很多咨询项目的人&#xff0c;发现很多人依旧停留在传统思维中&#xff0c;认为副业就是…...

R语言 基础 笔记 3

起因, 目的: 思考一个问题: AI 这么强,AI 什么都知道,为什么还要学习这些基础的东西, 为什么还要写这些笔记? 我觉得,大体过一遍,还是有好处的。 有个大致印象,下次查的时候,也方便一些。 几个函数 cbind() 按照列,拼接数据, 会改变某些列的数据类型。data() 查看…...

【MySQL】常见的SQL优化方式(一)

目录 1、插入数据 &#xff08;1&#xff09;批量插入 &#xff08;2&#xff09;手动提交事务 &#xff08;3&#xff09;主键顺序插入 2、主键优化 &#xff08;1&#xff09;页分裂 &#xff08;2&#xff09;页合并 3、order by 优化 &#xff08;1&#xff09;排…...

【重点】使用axios.request.put上传文件,报错分析

使用axios的put方法上传文件时&#xff0c;如果遇到错误&#xff0c;可能的原因有以下几点&#xff1a; 跨域问题&#xff1a;如果请求的URL与当前页面的域名不同&#xff0c;可能会触发跨域问题。解决方法是在服务器端设置允许跨域请求&#xff0c;如设置CORS&#xff08;跨域…...

最新最全的阿里大模型面试真题!看到就是赚到

前言 随着人工智能技术的飞速发展&#xff0c;计算机视觉&#xff08;CV&#xff09;、自然语言处理&#xff08;NLP&#xff09;、搜索、推荐、广告推送和风险控制等领域的岗位越来越受到追捧&#xff0c;掌握大型模型技术已成为这些岗位的必备技能。然而&#xff0c;目前公开…...

RestClient

什么是RestClient RestClient 是 Elasticsearch 官方提供的 Java 低级 REST 客户端&#xff0c;它允许HTTP与Elasticsearch 集群通信&#xff0c;而无需处理 JSON 序列化/反序列化等底层细节。它是 Elasticsearch Java API 客户端的基础。 RestClient 主要特点 轻量级&#xff…...

vscode里如何用git

打开vs终端执行如下&#xff1a; 1 初始化 Git 仓库&#xff08;如果尚未初始化&#xff09; git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...

设计模式和设计原则回顾

设计模式和设计原则回顾 23种设计模式是设计原则的完美体现,设计原则设计原则是设计模式的理论基石, 设计模式 在经典的设计模式分类中(如《设计模式:可复用面向对象软件的基础》一书中),总共有23种设计模式,分为三大类: 一、创建型模式(5种) 1. 单例模式(Sing…...

Spark 之 入门讲解详细版(1)

1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室&#xff08;Algorithms, Machines, and People Lab&#xff09;开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目&#xff0c;8个月后成为Apache顶级项目&#xff0c;速度之快足见过人之处&…...

ssc377d修改flash分区大小

1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...

《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (一)

CSI-2 协议详细解析 (一&#xff09; 1. CSI-2层定义&#xff08;CSI-2 Layer Definitions&#xff09; 分层结构 &#xff1a;CSI-2协议分为6层&#xff1a; 物理层&#xff08;PHY Layer&#xff09; &#xff1a; 定义电气特性、时钟机制和传输介质&#xff08;导线&#…...

ArcGIS Pro制作水平横向图例+多级标注

今天介绍下载ArcGIS Pro中如何设置水平横向图例。 之前我们介绍了ArcGIS的横向图例制作&#xff1a;ArcGIS横向、多列图例、顺序重排、符号居中、批量更改图例符号等等&#xff08;ArcGIS出图图例8大技巧&#xff09;&#xff0c;那这次我们看看ArcGIS Pro如何更加快捷的操作。…...

AspectJ 在 Android 中的完整使用指南

一、环境配置&#xff08;Gradle 7.0 适配&#xff09; 1. 项目级 build.gradle // 注意&#xff1a;沪江插件已停更&#xff0c;推荐官方兼容方案 buildscript {dependencies {classpath org.aspectj:aspectjtools:1.9.9.1 // AspectJ 工具} } 2. 模块级 build.gradle plu…...

Maven 概述、安装、配置、仓库、私服详解

目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...

以光量子为例,详解量子获取方式

光量子技术获取量子比特可在室温下进行。该方式有望通过与名为硅光子学&#xff08;silicon photonics&#xff09;的光波导&#xff08;optical waveguide&#xff09;芯片制造技术和光纤等光通信技术相结合来实现量子计算机。量子力学中&#xff0c;光既是波又是粒子。光子本…...