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

网站建设方案的内容2023年7月最新新闻摘抄

网站建设方案的内容,2023年7月最新新闻摘抄,云南app软件开发,企业网站建设需要提供什么内容文章目录 SpringBoot整合Easy-ES操作演示文档1 概述及特性1.1 官网1.2 主要特性 2 整合配置2.1 导入POM2.2 Yaml配置2.3 EsMapperScan 注解扫描2.4 配置Entity2.5 配置Mapper 3 基础操作3.1 批量保存3.2 数据更新3.3 数据删除3.4 组合查询3.5 高亮查询3.6 统计查询 4 整合异常4…

文章目录

  • SpringBoot整合Easy-ES操作演示文档
    • 1 概述及特性
      • 1.1 官网
      • 1.2 主要特性
    • 2 整合配置
      • 2.1 导入POM
      • 2.2 Yaml配置
      • 2.3 @EsMapperScan 注解扫描
      • 2.4 配置Entity
      • 2.5 配置Mapper
    • 3 基础操作
      • 3.1 批量保存
      • 3.2 数据更新
      • 3.3 数据删除
      • 3.4 组合查询
      • 3.5 高亮查询
      • 3.6 统计查询
    • 4 整合异常
      • 4.1 XContentType找不到问题

SpringBoot整合Easy-ES操作演示文档

1 概述及特性

1.1 官网

  • Easy-ES官网: https://www.easy-es.cn/
  • 官方示例: https://gitee.com/dromara/easy-es/tree/master/easy-es-sample
  • 参考链接: https://blog.51cto.com/yueshushu/6193710

1.2 主要特性

  • **零侵入:**针对ES官方提供的RestHighLevelClient只做增强不做改变,引入EE不会对现有工程产生影响,使用体验如丝般顺滑。
  • **损耗小:**启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作。
  • 自动化: 全球领先的哥哥你不用动,索引我全自动模式,帮助开发者和运维杜绝索引困扰。
  • 智能化: 根据索引类型和当前查询类型上下文综合智能判断当前查询是否需要拼接.keyword后缀,减少小白误用的可能。
  • **强大的 CRUD 操作:*内置通用 Mapper,仅仅通过少量配置即可实现大部分 CRUD 操作,更 有强大的条件构造器,满足各类使用需求。
  • **支持 Lambda 形式调用:**通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错段。
  • **支持主键自动生成:**支持多种主键策略,可自由配置,完美解决主键问题。
  • **支持 ActiveRecord 模式:**支持 ActiveRecord 形式调用,实体类只需继承 Model 类即可进行强大的 CRUD 操作。
  • **支持自定义全局通用操作:**支持全局通用方法注入( Write once, use anywhere )。
  • **内置分页插件:**基于RestHighLevelClient 物理分页,开发者无需关心具体操作,且无需额外配置插件,写分页等同于普通 List 查询,比MP的PageHelper插件用起来更简单,且保持与其同样的分页返回字段,无需担心命名影响。
  • **MySQL功能全覆盖:**MySQL中支持的功能通过EE都可以轻松实现。
  • **支持ES高阶语法:**支持聚合,嵌套,父子类型,高亮搜索,分词查询,权重查询,Geo地理位置查询,IP查询等高阶语法,应有尽有。
  • **良好的拓展性:*底层仍使用RestHighLevelClient,可保持其拓展性,开发者在使用EE的同时, * 仍可使用RestHighLevelClient的所有功能。

2 整合配置

2.1 导入POM

  • Latest Version: 2.0.0-beta4
<dependency><groupId>org.dromara.easy-es</groupId><artifactId>easy-es-boot-starter</artifactId><version>${Latest Version}</version>
</dependency>

2.2 Yaml配置

easy-es:# 基础配置项enable: trueaddress: 10.15.20.11:9200schema: httpusername:password:keep-alive-millis: 18000# 扩展的连接池配置项global-config:process-index-mode: smoothlyasync-process-index-blocking: trueprint-dsl: truedb-config:map-underscore-to-camel-case: trueid-type: customizefield-strategy: not_emptyrefresh-policy: immediateenable-track-total-hits: true

2.3 @EsMapperScan 注解扫描

  • 标注与主启动类上,功能与MP的@MapperScan一致。
package com.xs.easy;import org.dromara.easyes.starter.register.EsMapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;@EsMapperScan("com.xs.easy.mapper")
@EnableConfigurationProperties
@SpringBootApplication
public class XsEasyApplication {public static void main(String[] args) {SpringApplication.run(XsEasyApplication.class, args);}}

2.4 配置Entity

package com.xs.easy.entity;import lombok.Data;
import lombok.experimental.Accessors;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.Analyzer;
import org.dromara.easyes.annotation.rely.FieldStrategy;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;/*** es 数据模型**/
@Data
@Accessors(chain = true)
@IndexName(value = "easy-es-document", shardsNum = 3, replicasNum = 2, keepGlobalPrefix = true, maxResultWindow = 100)
public class Document {/*** es中的唯一id,如果你想自定义es中的id为你提供的id,比如MySQL中的id,请将注解中的type指定为customize或直接在全局配置文件中指定,如此id便支持任意数据类型)*/@IndexId(type = IdType.CUSTOMIZE)private String id;/*** 文档标题,不指定类型默认被创建为keyword类型,可进行精确查询*/private String title;/*** 文档内容,指定了类型及存储/查询分词器*/@HighLight(mappingField = "highlightContent")@IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART)private String content;/*** 作者 加@TableField注解,并指明strategy = FieldStrategy.NOT_EMPTY 表示更新的时候的策略为 创建者不为空字符串时才更新*/@IndexField(strategy = FieldStrategy.NOT_EMPTY)private String creator;/*** 创建时间*/@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")private String gmtCreate;/*** es中实际不存在的字段,但模型中加了,为了不和es映射,可以在此类型字段上加上 注解@TableField,并指明exist=false*/@IndexField(exist = false)private String notExistsField;/*** 地理位置经纬度坐标 例如: "40.13933715136454,116.63441990026217"*/@IndexField(fieldType = FieldType.GEO_POINT)private String location;/*** 图形(例如圆心,矩形)*/@IndexField(fieldType = FieldType.GEO_SHAPE)private String geoLocation;/*** 自定义字段名称*/@IndexField(value = "wu-la", fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_SMART, fieldData = true)private String customField;/*** 高亮返回值被映射的字段*/private String highlightContent;/*** 文档点赞数*/private Integer starNum;
}

2.5 配置Mapper

package com.xs.easy.mapper;import com.xs.easy.entity.Document;
import org.dromara.easyes.core.core.BaseEsMapper;/*** mapper 相当于Mybatis-plus的mapper**/
public interface DocumentMapper extends BaseEsMapper<Document> {}

3 基础操作

3.1 批量保存

    public Integer insertES(int num) {List<Document> lis = new ArrayList<>();for (int i = 0; i < num; i++) {Document document = new Document();document.setId(ChineseUtil.randomNumber(1, 1000000000) + "");document.setTitle(ChineseRandomGeneration.GBKMethod(16));document.setContent(ChineseRandomGeneration.GBKMethod(160));document.setCreator(ChineseUtil.randomChineseName());document.setGmtCreate(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));document.setStarNum(ChineseUtil.randomNumber(1, 10000));lis.add(document);}return this.documentMapper.insertBatch(lis);}

在这里插入图片描述

3.2 数据更新

    public Integer updateES(Document doc) {return this.documentMapper.updateById(doc);}

3.3 数据删除

    public Integer removeES(String id) {// 条件构造LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();wrapper.eq(Document::getId, id);return documentMapper.delete(wrapper);}

3.4 组合查询

    public List<Document> listByES(Document doc) {// 条件构造LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();wrapper.like(StringUtils.isNotBlank(doc.getTitle()), Document::getTitle, doc.getTitle());wrapper.like(StringUtils.isNotBlank(doc.getContent()), Document::getTitle, doc.getContent());return documentMapper.selectList(wrapper);}

在这里插入图片描述

3.5 高亮查询

    public List<Document> highSearchES(Document doc) {// 条件构造LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();wrapper.match(StringUtils.isNotBlank(doc.getContent()), Document::getContent, doc.getContent());return documentMapper.selectList(wrapper);}

在这里插入图片描述

3.6 统计查询

    public Long countTotal() {LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();return documentMapper.selectCount(wrapper);}

4 整合异常

4.1 XContentType找不到问题

  • java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/XContentType

在这里插入图片描述

  • 排除Easy-Es中的依赖
        <!-- Easy-ES --><dependency><groupId>org.dromara.easy-es</groupId><artifactId>easy-es-boot-starter</artifactId><!--排除依赖--><exclusions><exclusion><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId></exclusion><exclusion><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId></exclusion></exclusions></dependency>
  • 重新引入指定版本的组件
<properties><es.version>7.10.1</es.version><es-rest-high-level-client.version>7.10.1</es-rest-high-level-client.version>
</properties><!--新增依赖-->
<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>${es-rest-high-level-client.version}</version>
</dependency>
<dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>${es.version}</version>
</dependency>

在这里插入图片描述

http://www.shuangfujiaoyu.com/news/17381.html

相关文章:

  • 怎么看网站是什么时候做的湖南长沙seo教育
  • 网站动画用什么做的泉州百度开户
  • 市政府网站建设工作情况汇报搜索引擎优化seo方案
  • 广州知名网站推广搜一搜百度
  • 做一钓鱼网站吗网站建设与网站设计
  • 做贷款网站犯法吗友情链接属于免费推广吗
  • imap 做网站seo手机排名软件
  • 网络营销 长沙搜索优化师
  • 不花钱做网站seo中文意思是
  • 网站建设公司该怎么销售自助发稿
  • 导航网站怎么做点击网站建设的重要性
  • 网站正能量免费下载重庆网站外包
  • 南阳河南网站建设如何推广宣传一个品牌
  • ps怎么做网站视频特效灰色关键词排名技术
  • 网站建设工作基本流程灰色词优化培训
  • 动态asp.net网站开发电脑培训学校在哪里
  • 做网站需要下什么软件抓关键词的方法10条
  • 婚礼网站怎么做的自己手机怎么免费做网站
  • 网站开发公司盈利石家庄网站建设方案推广
  • 做网站用微软雅黑字体被告侵权成都最好的网站推广优化公司
  • 网站做点击广告是怎么回事谷歌广告优化师
  • 北京网站建设公司空间续费北京百度热门搜索排行榜
  • 网络营销是什么的一项活动北京seo推广外包
  • 物流网站给做软件下载百度推广开户
  • 网站应该设计成什么样企业网站是什么
  • 外贸可以什么网站做如何推广引流
  • 广州公司转让交易平台seo搜索排名优化是什么意思
  • 网站建设公众号开长沙做搜索引擎的公司
  • 网站设计 日语百度推广可以自己开户吗
  • 如何提高 网站的点击量西安seo网站关键词