Check it out on github
demo-elastic-search
DESC:
- spring 整合 elasticsearch
- spring 整合 mybatis-plus
- 包含事件封装代码练习
- demo_test 没有连接数据库
- demo_article 连接了数据库
快速上手:
准备:
** ES 6-2-2下载地址 **
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-2-2
** ik 分词器下载 **
https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.2.2
解压所有文件复制到elasticsearch的plugins目录下(可以在plugins下新建ik文件夹,放在里面方便更多插件整理)
** 最近参考的ES查询API **
https://docs.spring.io/spring-data/elasticsearch/docs/3.0.8.RELEASE/reference/html/#repositories
pom.xml
<!-- es 启动器, 7.0+ 需手动整合,配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
application.yml
spring:
# 配置 es
data:
elasticsearch:
cluster-name: my-application
cluster-nodes: 127.0.0.1:9300
demo
配置类
package com.quaint.demo.es.config;
@Configuration
public class ElasticSearchConfig {
/**
* 创建elasticsearchTemplate
* @param client
* @param converter
* @return
*/
@Bean