畅购商城(五):Elasticsearch实现商品搜索

2020-10-17 16:01:54 蜻蜓队长

好好学习,天天向上

本文已收录至我的Github仓库DayDayUP:github.com/RobodLee/DayDayUP,欢迎Star,更多文章请前往:目录导航

前期准备

今天的任务就是用ElasticSearcher实现商品搜索的功能。关于Elasticsearch、IK分词器、Kibana的安装及基本使用可以看我的另一篇文章Elasticsearch入门指南

搜索微服务的API工程的搭建

在changgou-service-api下创建一个Module叫changgou-service-search-api。我们后面所要是实现的功能都是基于Spring Data ElasticSearch实现的,所以相关依赖不能少:

<dependencies>
    <!--goods API依赖-->
    <dependency>
        <groupId>com.robod</groupId>
        <artifactId>changgou-service-goods-api</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!--SpringDataES依赖-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>
</dependencies>
复制代码

搜索微服务搭建

changgou-service下新建一个changgou-service-search工程作为搜索微服务。在搜索微服务里面需要用到API工程的JavaBean和Feign接口,所以将search-api和goods-api作为依赖添加进来。

<dependencies>
    <!--依赖search api-->
    <dependency>
        <groupId>com.robod</groupId>
        <artifactId>changgou-service-search-api</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.robod</groupId>
        <artifactId>changgou-service-goods-api</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>
复制代码

启动类和配置文件自然不能少

以上内容来自于网络,如有侵权联系即删除
相关文章

上一篇: Flutter 生成图形验证码

下一篇: 老司机 iOS 周报 #113 | 2020-05-18

在线咨询
客户经理