Java之ElasticSearch入门Demo

java springboot 整合 ElasticSearch 入门 demo
摘要由CSDN通过智能技术生成

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
    
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值