项目作者: Motianshi

项目描述 :
??【搜索系统】基于ElasticSearch7.3.2、RestHighLevelClient、SpringBoot搭建的通用搜索系统脚手架,帮助开发者快速搭建搜索系统。
高级语言: Java
项目地址: git://github.com/Motianshi/all-search.git
创建时间: 2019-09-26T09:28:58Z
项目社区:https://github.com/Motianshi/all-search

开源协议:

下载


博客
版本
公众号

简介

  • 基于ElasticSearch7.3.2版本的通用搜索系统
  • 使用rest-high-level-client操作ES
  • 封装常用api,包含索引的CRUD、文档的CRUD、索引定制化、模糊搜索、精准匹配搜索
  • 是一套操作简单的搜索系统脚手架,稍加修改即可在项目中快速搭建起搜索系统

使用rest-high-level-client整合Es的原因

  • TransportClient 存在并发瓶颈
  • rest-client 版本较低无法支持新特性
  • SpringBoot的Es模板ElasticsearchRepository更新较慢,不支持高版本的ES

使用方式

git clone按需复制到自己的项目里即可

组件版本

组件 Version
Elasticsearch 7.3.2
Elasticsearch-rest-high-level-client 7.3.2
Fastjson 1.2.60
SpringBoot 2.1.0.RELEASE

目录

  1. ├── src
  2. ├── main
  3. ├── java
  4. └── com
  5. └── anqi
  6. └── es
  7. ├── DemoEsApplication.java
  8. ├── Main.java
  9. ├── client
  10. └── ESClientConfig.java 老版本RestClient封装,这里不会使用
  11. ├── controller
  12. └── EsController.java 搜索测试接口
  13. ├── highclient
  14. ├── RestHighLevelClientConfig.java Client配置
  15. └── RestHighLevelClientService.java 搜索API
  16. └── util
  17. └── SnowflakeIdWorker.java Twitter的雪花算法用来生成文档id
  18. └── resources
  19. ├── application.properties
  20. ├── static
  21. └── templates
  22. ├── pom.xml

maven说明

因为elasticsearch-rest-high-level-client7.3.2 依赖 elasticsearch 6.4.2 和 elasticsearch-rest-client 6.4.2 ,而目前这已经是中央仓库中最高版本的jar包了(8.0.0)还未迁入中央仓库,所以我们手动引入7.3.2的新版本elasticsearch和elasticsearch-rest-client

  1. <!-- high client-->
  2. <dependency>
  3. <groupId>org.elasticsearch.client</groupId>
  4. <artifactId>elasticsearch-rest-high-level-client</artifactId>
  5. <version>7.3.2</version>
  6. <exclusions>
  7. <exclusion>
  8. <groupId>org.elasticsearch.client</groupId>
  9. <artifactId>elasticsearch-rest-client</artifactId>
  10. </exclusion>
  11. <exclusion>
  12. <groupId>org.elasticsearch</groupId>
  13. <artifactId>elasticsearch</artifactId>
  14. </exclusion>
  15. </exclusions>
  16. </dependency>
  17. <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
  18. <dependency>
  19. <groupId>org.elasticsearch</groupId>
  20. <artifactId>elasticsearch</artifactId>
  21. <version>7.3.2</version>
  22. </dependency>
  23. <!--rest low client-->
  24. <dependency>
  25. <groupId>org.elasticsearch.client</groupId>
  26. <artifactId>elasticsearch-rest-client</artifactId>
  27. <version>7.3.2</version>
  28. </dependency>
  29. <!-- springboot-->
  30. <dependency>
  31. <groupId>org.springframework.boot</groupId>
  32. <artifactId>spring-boot-starter-web</artifactId>
  33. </dependency>
  34. <dependency>
  35. <groupId>org.springframework.boot</groupId>
  36. <artifactId>spring-boot-starter-test</artifactId>
  37. <scope>test</scope>
  38. </dependency>