需要一个集成solr和elastic的项目,之前用PHP做了一版,功能基本上实现了 。本着学习的态度,用比较火的springboot重新构建一遍。记录一下过程。因为是边构建边记录,后终效果我也不知道。
1.选型
springboot + jpa + thymeleaf
安全框架springsecurity
数据库mysql 本机的是5.7
搜索引擎:截止目前最新elastic7.10+solr8.7
2.目标
- 同时支持配置两者的索引
- 分类搜索(此时支持按字段搜索)
- 全文搜索
- 结果中搜索
- 结构化数据的展示模板配置
- 高亮搜索词
- elastic和solr支持中文分词,tika文件索引
3.环境准备
mysql:本机已安装5.7
elastic:
https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-install.html
下载文件包
解压文件包
打开CMD,运行
bin/elasticsearch.bat
提示我们在9200已经启动了一个es的实例
浏览器打开9200
es基本配置完毕
solr:
https://lucene.apache.org/solr/downloads.html
下载文件包
解压文件包
打开CMD
执行solr.cmd start,提示在8983端口已经成功启动了一个solr实例
浏览器打开本机8983端口
solr基本配置已完成
springboot配置
本机的eclipse版本是Version: 2018-09 (4.9.0)
maven版本是eclipse自带的3.5.3
打开
填写完成后generate.右边的包可以大概选一下,后续可以在pom文件里再配置
下载后解压。eclipse导入maven项目
我这里报了个错
Project build error: Non-resolvable parent POM for cn.wjh:jw:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.5.0-SNAPSHOT from https://repo.spring.io/milestone was cached in the local repository, resolution will not be reattempted until the update interval of spring-milestones has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.0-SNAPSHOT from/to spring-milestones (https://repo.spring.io/milestone): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at no local POM
repo.spring.io不在jdk的信任证书列表中,添加就可以了。之前的博文里写过,就不再详细记录了。
这里用的是java15,没有jre目录。用命令:bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre
生成jre后添加信任域名