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

企业网站建设项目策划书/企业如何开展网络营销

企业网站建设项目策划书,企业如何开展网络营销,网站建设实训报告心得,网站开发看什么书1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.6.3</version> </dependency> 2.config配置文件 Configu…

1.引入依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <version>2.6.3</version>
</dependency>

2.config配置文件

@Configuration
public class RestClientConfig extends AbstractElasticsearchConfiguration {@Override@Beanpublic RestHighLevelClient elasticsearchClient() {final ClientConfiguration clientConfiguration =ClientConfiguration.builder().connectedTo("xx.xxx.xxx.xx:9200") //地址.build();return RestClients.create(clientConfiguration).rest();}
}

         会返回两个客户端对象,分别是ElasticsearchOperations和RestHighLevelClient(更推荐使用)。前者是通过面向对象的形式来操作的,后者是通过客户端的方式操作的。

3.索引相关操作

/*索引相关操作*/
public class Test1 {RestHighLevelClient restHighLevelClient;@Beforepublic void init(){final ClientConfiguration clientConfiguration =ClientConfiguration.builder().connectedTo("xx.xxxx.xxx.xx:xxxx").build();this.restHighLevelClient = RestClients.create(clientConfiguration).rest();}@Test//创建索引public void createIndex() throws IOException {CreateIndexRequest createIndexRequest = new CreateIndexRequest("products");//指定映射 参数1:指定映射json结构 参数2:指定数据类型createIndexRequest.mapping("{\n" +"    \"properties\": {\n" +"        \"id\":{\n" +"          \"type\":\"integer\"\n" +"        },\n" +"        \"title\":{\n" +"          \"type\":\"keyword\"\n" +"        },\n" +"        \"price\":{\n" +"          \"type\":\"double\"\n" +"        },\n" +"        \"created_at\":{\n" +"          \"type\":\"date\"\n" +"        },\n" +"        \"description\":{\n" +"          \"type\":\"text\",\n" +"          \"analyzer\": \"ik_max_word\"\n" +"        }\n" +"    }\n" +"  }", XContentType.JSON);//参数1:创建索引请求对象  参数2:请求配置对象CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);System.out.println("创建状态:"+createIndexResponse.isAcknowledged()); //打印返回信息restHighLevelClient.close(); //关闭资源}@Test//删除索引public void deleteIndex() throws IOException {AcknowledgedResponse acknowledgedResponse = restHighLevelClient.indices().delete(new DeleteIndexRequest("products"), RequestOptions.DEFAULT);System.out.println("删除状态:"+acknowledgedResponse.isAcknowledged()); //打印返回信息restHighLevelClient.close(); //关闭资源}
}

4.文档相关操作

/*文档相关操作(document)*/
public class Test2 {RestHighLevelClient restHighLevelClient;@Beforepublic void init(){final ClientConfiguration clientConfiguration =ClientConfiguration.builder().connectedTo("xx.xxx.xxx.xx:9200").build();this.restHighLevelClient = RestClients.create(clientConfiguration).rest();}@Test  //创建文档public void createDoc() throws IOException {IndexRequest indexRequest = new IndexRequest("products");indexRequest.id("2") //手动指定文档的id,如果不指定则会用uuid.source("{\n" +"  \"title\":\"瑞星咖啡\",\n" +"  \"price\": 9.8,\n" +"  \"created_at\":\"2023-11-18\",\n" +"  \"description\":\"瑞星咖啡我最爱了,好喝\"\n" +"}", XContentType.JSON);//参数1:索引请求对象,参数2:请求配置对象IndexResponse indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);System.out.println(indexResponse.status());restHighLevelClient.close();}@Test  //修改文档public void updateDoc() throws IOException {UpdateRequest updateRequest = new UpdateRequest("products","1");updateRequest.doc("{\n" +"    \"title\":\"库迪咖啡非\"\n" +"  }",XContentType.JSON);//参数1:索引请求对象,参数2:请求配置对象UpdateResponse updateResponse = restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);System.out.println(updateResponse.status());restHighLevelClient.close();}@Test  //删除文档public void deleteDoc() throws IOException {DeleteRequest deleteRequest = new DeleteRequest("products","2");//参数1:索引请求对象,参数2:请求配置对象DeleteResponse deleteResponse = restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);System.out.println(deleteResponse.status());restHighLevelClient.close();}@Test  //基于id查询文档public void searchDocById() throws IOException {GetRequest getRequest = new GetRequest("products", "1");GetResponse getResponse = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT);System.out.println(getResponse.getId());System.out.println(getResponse.getSourceAsString());}}

5.高级查询

public class Test3 {RestHighLevelClient restHighLevelClient;@Beforepublic void init(){final ClientConfiguration clientConfiguration =ClientConfiguration.builder().connectedTo("xx.xxx.xxx.xx:9200").build();this.restHighLevelClient = RestClients.create(clientConfiguration).rest();}@Test //查询一个索引中的所有文档public void searchAll() throws IOException {SearchRequest searchRequest = new SearchRequest("products");searchRequest.source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()));//查询所有//参数1:搜索请求对象 参数2:请求配置对象SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);System.out.println("查询出来的总条数:"+searchResponse.getHits().getTotalHits().value);System.out.println("查询出来的最大得分"+searchResponse.getHits().getMaxScore());//拿到数据结果SearchHit[] hits = searchResponse.getHits().getHits();for(SearchHit hit:hits){String id = hit.getId();System.out.println("id: "+id+" source: "+hit.getSourceAsString());}}@Test //基于关键词查询public void search() throws IOException {SearchRequest searchRequest = new SearchRequest("products");searchRequest.source(new SearchSourceBuilder().query(QueryBuilders.termQuery("description","好喝")));//查询所有//参数1:搜索请求对象 参数2:请求配置对象SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);System.out.println("查询出来的总条数:"+searchResponse.getHits().getTotalHits().value);System.out.println("查询出来的最大得分"+searchResponse.getHits().getMaxScore());//拿到数据结果SearchHit[] hits = searchResponse.getHits().getHits();for(SearchHit hit:hits){String id = hit.getId();System.out.println("id: "+id+" source: "+hit.getSourceAsString());}}/** 分页查询* 排序* 字段*/@Test //分页查询 与排序public void search2() throws IOException {SearchRequest searchRequest = new SearchRequest("products");SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();searchSourceBuilder.query(QueryBuilders.matchAllQuery()).from(1) //起始位置 start=(page-1)*size.size(1) //每页显示条数.sort("price", SortOrder.ASC) //字段排序.fetchSource(new String[]{},new String[]{"created_at"}); //参数1:包含字段数组  参数2:排除字段数组searchRequest.source(searchSourceBuilder);//查询所有//参数1:搜索请求对象 参数2:请求配置对象SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);System.out.println("查询出来的总条数:"+searchResponse.getHits().getTotalHits().value);System.out.println("查询出来的最大得分"+searchResponse.getHits().getMaxScore());//拿到数据结果SearchHit[] hits = searchResponse.getHits().getHits();for(SearchHit hit:hits){String id = hit.getId();System.out.println("id: "+id+" source: "+hit.getSourceAsString());}}@Test //高亮public void search3() throws IOException {SearchRequest searchRequest = new SearchRequest("products");SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();HighlightBuilder highlightBuilder = new HighlightBuilder();highlightBuilder.requireFieldMatch(false).field("description").field("title").preTags("<span style='color:red;'>").postTags("</span>");searchSourceBuilder.query(QueryBuilders.termQuery("description","好喝")).highlighter(highlightBuilder);searchRequest.source(searchSourceBuilder);//查询所有//参数1:搜索请求对象 参数2:请求配置对象SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);System.out.println("查询出来的总条数:"+searchResponse.getHits().getTotalHits().value);System.out.println("查询出来的最大得分"+searchResponse.getHits().getMaxScore());//拿到数据结果SearchHit[] hits = searchResponse.getHits().getHits();for(SearchHit hit:hits){System.out.println("id: "+hit.getId()+" source: "+hit.getSourceAsString());//获取高亮字段Map<String, HighlightField> highlightFields = hit.getHighlightFields();if(highlightFields.containsKey("description")){System.out.println("description高亮结果: "+highlightFields.get("description").fragments()[0]);}if(highlightFields.containsKey("title")){System.out.println("title高亮结果: "+highlightFields.get("title").fragments()[0]);}}}@Test //过滤查询public void search4() throws IOException {SearchRequest searchRequest = new SearchRequest("products");SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();searchSourceBuilder.query(QueryBuilders.matchAllQuery()).postFilter(QueryBuilders.idsQuery().addIds("1")); //指定过滤条件searchRequest.source(searchSourceBuilder);//查询所有//参数1:搜索请求对象 参数2:请求配置对象SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);System.out.println("查询出来的总条数:"+searchResponse.getHits().getTotalHits().value);System.out.println("查询出来的最大得分"+searchResponse.getHits().getMaxScore());//拿到数据结果SearchHit[] hits = searchResponse.getHits().getHits();for(SearchHit hit:hits){String id = hit.getId();System.out.println("id: "+id+" source: "+hit.getSourceAsString());}}
}

相关文章:

SpringBoot整合ES

1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.6.3</version> </dependency> 2.config配置文件 Configu…...

Pandas实战100例 | 案例 10: 应用函数 - 使用 `apply`

案例 10: 应用函数 - 使用 apply 知识点讲解 Pandas 的 apply 函数是一个非常强大的工具&#xff0c;允许你对 DataFrame 中的行或列应用一个函数。这对于复杂的数据转换和计算非常有用。你可以使用 apply 来执行任意的函数&#xff0c;这些函数可以是自定义的&#xff0c;也…...

《C++大学教程》4.13汽油哩数

题目: 每位司机都关心自己车辆的行车里程数。有位司机通过记录每次出行所行驶的英里数和用油的加仑数来跟踪他多次出车的情况。请开发一个C程序&#xff0c;它使用一条while语句输入每次出车的行驶英里数和加油量。该程序应计算和显示每次出车所得到的每加仑行驶英里数&#x…...

OpenGL排坑指南—贴图纹理绑定和使用

一、前言 在OpenGL学习 的纹理这一章中讲述了纹理贴图的使用方式&#xff0c;主要步骤是先创建一个纹理的对象&#xff0c;和创建顶点VAO类似&#xff0c;然后就开始绑定这个纹理&#xff0c;最后在循环中使用&#xff0c;有时候可能还要用到激活纹理单元的函数。然而&#xff…...

Electron中 主进程(Main Process)与 渲染进程 (Renderer Process) 通信的方式

1. 渲染进程向主进程通信 修改 html 文件内容 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><!-- 解决控制…...

企业微信forMAC,如何左右翻动预览图片

1、control commandshifd 进入企业微信的debug调试模式 2、按照如下步骤选择 3、重启企业微信...

Android Firebase (FCM)推送接入

官方文档&#xff1a; 向后台应用发送测试消息 | Firebase Cloud Messaging 1、根级&#xff08;项目级&#xff09;Gradlegradle的dependencies中添加&#xff1a; dependencies {...// Add the dependency for the Google services Gradle pluginclasspath com.google.gm…...

Neo4j恢复

主要记录windows环境下从备份文件中恢复Neo4j&#xff0c; Linux环境同理 备份在上一篇中有介绍&#xff0c;参考: Neo4j备份-CSDN博客 误删数据 为了模拟误删除场景&#xff0c;我们查询Person&#xff0c;并模拟误操作将其进行删除&#xff1b; match(p:Person) return …...

ZZULIOJ 1114: 逆序

题目描述 输入n&#xff08;1<n<10&#xff09;和n个整数&#xff0c;逆序输出这n个整数。 输入 输入n&#xff08;1<n<10&#xff09;&#xff0c;然后输入n个整数。 输出 逆序输出这n个整数&#xff0c;每个整数占4列&#xff0c;右对齐。 样例输入 Copy …...

Linux前后端项目部署

目录 1.jdk&tomcat安装 配置并且测试jdk安装 修改tomcat 配置文件 登入tomcat 发布 安装mysql 导入sql数据 发布项目war包 redis安装 nginx安装 配置nginx域名映射 部署前端项目 centos 7的服务安装 安装jdk 安装tomcat 安装Mysql 安装redis 安装nginx 前后…...

GPT-4与DALL·E 3:跨界融合,开启绘画与文本的新纪元

在人工智能的发展浪潮中&#xff0c;MidTool&#xff08;https://www.aimidtool.com/&#xff09;的GPT-4与DALLE 3的集成代表了一个跨越式的进步。这一集成不仅仅是技术的结合&#xff0c;更是艺术与文字的完美融合&#xff0c;它为创意产业带来了革命性的变革。本文将探讨GPT…...

聊聊PowerJob的Alarmable

序 本文主要研究一下PowerJob的Alarmable Alarmable tech/powerjob/server/extension/Alarmable.java public interface Alarmable {void onFailed(Alarm alarm, List<UserInfoDO> targetUserList); }Alarmable接口定义了onFailed方法&#xff0c;其入参为alarm及tar…...

系列三十五、获取Excel中的总记录数

一、获取Excel中的总记录数 1.1、概述 使用EasyExcel开发进行文件上传时&#xff0c;通常会碰到一个问题&#xff0c;那就是Excel中的记录数太多&#xff0c;使用传统的方案进行文件上传&#xff0c;很容易就超时了&#xff0c;这时可以通过对用户上传的Excel中的数量进行限制…...

VMware workstation安装debian-12.1.0虚拟机并配置网络

VMware workstation安装debian-12.1.0虚拟机并配置网络 Debian 是一个完全自由的操作系统&#xff01;Debian 有一个由普罗大众组成的社区&#xff01;该文档适用于在VMware workstation平台安装debian-12.1.0虚拟机。 1.安装准备 1.1安装平台 Windows 11 1.2软件信息 软…...

centos下系统全局检测工具dstat使用

目录 一&#xff1a;没有需要安装 二&#xff1a;dstat命令参数 三、监测界面各参数含义&#xff08;部分&#xff09; 四、dstat的高级用法 一&#xff1a;没有需要安装 yum install dstat 二&#xff1a;dstat命令参数 有默认选项&#xff0c;执行dstat命令不加任何参数…...

无人机群ros通信

单架无人机与地面站通信 在一个局域网内获取无人机的机载电脑ip 通过地面站ssh到机载电脑&#xff0c;实现通信 多架无人机与地面站通信 在ROS基础上&#xff0c;配置主机和从机&#xff0c;实现主机和从机的话题联通 配置hosts 在主机和从机的/etc/hosts文件中&#xff0c…...

LeetCode刷题:142. 环形链表 II

题目&#xff1a; 是否独立解决&#xff1a;否&#xff0c;参考了解题思路解决问题&#xff0c;思考了用快慢指针&#xff0c;栈&#xff0c;统计链表数量定位尾巴节点&#xff08;因为是环形链表所以是死循环&#xff0c;链表数量用while循环统计不出来&#xff09;都没解决 解…...

Laravel 使用rdkafka_laravel详细教程(实操避坑)

一、选择rdkafka 首先要看版本兼容问题&#xff0c;我的是Laravel5.6&#xff0c;PHP是7.3.13&#xff0c;所以需要下载兼容此的rdkafka&#xff0c;去 Packagist 搜索 kafka &#xff0c;我用的是 enqueue/rdkafka选择里面0.10.5版本&#xff0c; 二、安装rdkafka 在 Larav…...

439 - Knight Moves (UVA)

题目链接如下&#xff1a; Online Judge UVA439 骑士的移动 - 锦依卫议事堂 - 洛谷博客 这里有好几个特别厉害的解法...先存着慢慢看。 我的代码如下&#xff1a; #include <iostream> #include <deque> #include <string> // #define debugstruct node{…...

数据结构(c)冒泡排序

本文除了最下面的代码是我写的&#xff0c;其余是网上抄写的。 冒泡排序 什么是冒泡排序&#xff1f; 冒泡排序&#xff08;Bubble Sort&#xff09;是一种简单的排序算法。它重复地走访过要排序的数列&#xff0c;一次比较两个元素&#xff0c;如果他们的顺序错误就把他们交…...

并发编程之并发容器

目录 并发容器 CopyOnWriteArrayList 应用场景 常用方法 读多写少场景使用CopyOnWriteArrayList举例 CopyOnWriteArrayList原理 CopyOnWriteArrayList 的缺陷 扩展迭代器fail-fast与fail-safe机制 ConcurrentHashMap 应用场景 常用方法 并发场景下线程安全举例 Con…...

K8s---存储卷(动态pv和pvc)

当我要发布pvc可以生成pv&#xff0c;还可以共享服务器上直接生成挂载目录。pvc直接绑定pv。 动态pv需要两个组件 1、卷插件&#xff1a;k8s本生支持的动态pv创建不包括nfs&#xff0c;需要声明和安装一个外部插件 Provisioner: 存储分配器。动态创建pv,然后根据pvc的请求自动…...

JS判断对象是否为空对象的几种方法

通过JSON自带的stringify()方法判断 function isEmptyObj(obj) {return JSON.stringify(obj) {} } console.log(对象是否为空&#xff1a;, isEmptyObj({}))for in 循环判断 function isEmptyObj(obj) {for(let item in obj) {return true}return false } console.log(对…...

算法通关村第十五关—用4KB内存寻找重复元素(青铜)

用4KB内存寻找重复元素 用4KB内存寻找重复元素 题目要求&#xff1a;给定一个数组&#xff0c;包含从1到N的整数&#xff0c;N最大为32000&#xff0c;数组可能还有重复值&#xff0c;且N的取值不定&#xff0c;若只有4KB的内存可用&#xff0c;该如何打印数组中所有重复元素。…...

【PHP】判断字符串是否是有效的base64编码

目录 1.检测长度&#xff1a; 2.检查字符集&#xff1a; 3.判断是否能正常解码 在PHP中&#xff0c;判断一个字符串是否是有效的Base64编码&#xff0c;可以通过以下几种方法&#xff1a; 1.检测长度&#xff1a; Base64编码的字符串长度必须是4的倍数&#xff08;对于标准…...

鼎盛合|测量精度SOC芯片开发中的技术问题整理

SOC芯片近几年的发展势头迅猛&#xff0c;许多行业中俱可见其身影。SOC芯片并不是传统意义上的芯片&#xff0c;它是一个由多种功能集成的一个芯片。SOC芯片自身在出厂时便带有部分程序&#xff0c;是为了方便设计开发而针对某些行业设计的特定功能。如芯海的SOC芯片大多数则是…...

sql | 学生参加各科考试次数

学生表: Students------------------------ | Column Name | Type | ------------------------ | student_id | int | | student_name | varchar | ------------------------ 在 SQL 中&#xff0c;主键为 student_id&#xff08;学生ID&#xff09;。 该表内的每…...

uniapp(vue2)+VoerkaI18n多语言

今天我学习了VoerkaI18n国际化插件&#xff0c;它是一个适用于Javascript/Vue/React/Solid/ReactNative的国际化全流程解决方案。VoerkaI18n可以帮助我们轻松地实现应用程序的多语言支持&#xff0c;使得应用程序可以适应不同的语言环境。 比较吸引我的是集成自动翻译,t(“中华…...

C51--测速小车

测速小车&#xff1a; 测速模块&#xff1a; 用途&#xff1a; 广泛用于电机转速检测&#xff0c;脉冲计数&#xff0c;位置限位等。 高低电平&#xff1a; 有遮挡&#xff0c;输出高电平&#xff1b; 无遮挡&#xff0c;输出低电平。 接线&#xff1a; VCC——正极 GND——接…...

ORACLE报错:ORA-04091 表XXX发生了变化,触发器/函数不能读它

ORACLE报错:ORA-04091 表发XXX生了变化&#xff0c;触发器/函数不能读它 问题描述问题分析解决办法拓展&#xff1a;自治事务的特点 问题描述 在开发校验函数FUNCTION的时候&#xff0c;用数据跑批测试的时候报错。经排查这个校验函数FUNCTION的被一个存储过程中的update语句调…...