超詳細 SpringBoot 整合 Elasticsearch .md

SpringBoot 整合 Elasticsearch (超詳細)注意:1、環境搭建安裝es【超詳細 SpringBoot 整合 Elasticsearch .md】Elasticsearch 6.4.3 下載鏈接
為了方便,環境使用Windows
配置解壓后配置

  • 找到config目錄的elasticsearch.yml
分詞器
  • 默認的Es是不支持中文分詞的,下載ik分詞器(下載的版本要與Es保持一致)
  • Elasticsearch-ik 6.4.3 下載鏈接
下圖所示,解壓后的分詞器放在plugins目錄下,ik目錄需要自己創建啟動
  • 由于我是在Windows環境下,找到bin目錄的elasticsearch.bat雙擊即可 。
命令測試
  • 查看健康狀態
    • curl -X GET “localhost:9200/_cat/health?v“
  • 查看所有節點
    • curl -X GET “localhost:9200/_cat/nodes?v“
  • 新建索引
    • curl -X PUT "localhost:9200/test"
  • ? 查看索引
    • curl -X GET "localhost:9200/_cat/indices?v"
  • 刪除索引
    • curl -X DELETE "localhost:9200/test"
2、整合 Es依賴 & 配置
  • 我這里使用的是SpringBoot 2.1.5.RELEASE,根據實際情況選擇版本 。
<!--elasticsearch-->        <dependency>            <groupId>org.springframework.data</groupId>            <artifactId>spring-data-elasticsearch</artifactId>            <version>2.1.6.RELEASE</version>        </dependency>
  • yaml配置

    推薦閱讀