为了账号安全,请及时绑定邮箱和手机立即绑定

Springboot + ElasticSearch 构建博客检索系统

难度中级
时长 2小时40分
学习人数
综合评分9.60
41人评价 查看评价
9.6 内容实用
9.7 简洁易懂
9.5 逻辑清晰
  • 倒排索引规则



    查看全部
    0 采集 收起 来源:基于ES实现

    2020-05-09

  • 同步方法,es官方提供的logstash

    命令: logstash -f ../config/mysql.conf

    mysql.conf:

    input {

      jdbc {

    jdbc_driver_library => "E:\\es\logstash-6.5.2\\mysql-connector-java-5.1.43.jar"

        jdbc_driver_class => "com.mysql.jdbc.Driver"

        jdbc_connection_string => "jdbc:mysql://localhost:3306/mp"

        jdbc_user => "root"

        jdbc_password => "ROOT"

        schedule => "* * * * *"

        clean_run => true

        statement => "select * from tb_blog  where create_time > :sql_last_value and create_time < NOW() order by create_time desc"

      }

    }

    output {

      elasticsearch {

        hosts => ["http://localhost:9200"]

        index => "blog"

        document_id => "%{id}"

      }

    }

    查看全部
  • springboot解决前端跨域问题配置

    http://img1.sycdn.imooc.com//5e8ef21c00015f2f13460677.jpg

    查看全部
  • 通过es条件查询封装过程

    http://img1.sycdn.imooc.com//5e8eefd70001c6e313040631.jpg

    查看全部
  • 新增数据-person

    {"first_name" : "John",

    "last_name" : "Smith",

    "age" : 25,

    "about" : "Hello world",

    "interests" :["music","Sports"]}


    查看全部
  • spring自带的耗时统计,StopWatch watch = new StopWatch();

    watch.start();

    watch.stop();

    long time = watch.getTotalTimeMillis();

    查看全部
  • ES的dao接口

    http://img1.sycdn.imooc.com//5e8ee27a0001ce7f10730377.jpg

    查看全部
    0 采集 收起 来源:springboot 集成ES

    2020-04-09

  • 使用线上的es配置,createIndex=false就是启动springboot时候不去创建index,避免删除线上的index

    http://img1.sycdn.imooc.com//5e8ee1da0001f55810470682.jpg

    查看全部
    0 采集 收起 来源:springboot 集成ES

    2020-04-09

  • springboot里引入lombok依赖(新建项目时就可选择),可在实体类上配置@Data,就能省略get,set方法编写,这里还差个@Entity配置

    http://img4.sycdn.imooc.com/5e8ed7f0000156f311520580.jpg

    查看全部
  • es分词器类型:(可下载第三方插件分词器,有对中文更好的支持)

    http://img3.sycdn.imooc.com/5e8e900f00013f6110410561.jpg

    查看全部
    0 采集 收起 来源:分词器介绍

    2020-04-10

  • mysql和es数据同步,es官方提供的logstash

    迁移命令: logstash -f ../config/mysql.conf

    配置内容:

    input {

      jdbc {

        jdbc_driver_library => "D:\\es\logstash-7.6.2\\mysql-connector-java-5.1.37-bin.jar"

        jdbc_driver_class => "com.mysql.jdbc.Driver"

        jdbc_connection_string => "jdbc:mysql://192.168.0.132:3306/estest"

        jdbc_user => "root"

        jdbc_password => "root"

        schedule => "* * * * *"

        clean_run => true

        statement => "select * from user where createtime > :sql_last_value and createtime < NOW() order by createtime desc"

      }

    }

    output {

      elasticsearch {

        hosts => ["http://localhost:9200"]

        index => "user"

        document_id => "%{code}"

      }

    }


    查看全部
  • 刚好在数据同步的时候,mysql有新的数据插入,可采用createtime时间,每次增量同步上次时间到现在最新时间段内的数据

    查看全部
  • ES在存入数据的时候,就会对数据进行分词,对查询搜索效率提升

    查看全部
    0 采集 收起 来源:基于ES实现

    2020-04-08

  • ES条件查询(可省略_doc),should里可有多个match,相当于or语句,should改成must,就变成了and语句

    POST /person/_search

    {

      "query": {

        "bool": {

          "should": [

            {

              "match": {

                "last_name": "Simth"

              }

            },

            {

              "match": {

                "about": "love"

              }

            }

          ]

        }

      }

    }


    查看全部
  • es根据主键查询:GET /person/_doc/1

    查看全部

举报

0/150
提交
取消
课程须知
开始课程学习之前,小伙伴们需要熟悉JAVA web开发,并要有一定mysql操作基础,如对Vue有一定了解学习效果更佳!
老师告诉你能学到什么?
1、ElasticSearch概念和适用场景 2、ElasticSearch 数据类型,和关系型数据库的对比 3、Mysql数据同步到ES(logstash, mysql binlog, 第三方Go 框架) 4、Springboot 操作ES 5、ElasticSearch 安装中文分词器

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!