没有合适的资源?快使用搜索试试~ 我知道了~
首页SpringBoot集成Elasticsearch7.4 实战.pdf
SpringBoot集成Elasticsearch7.4 实战.pdf
4星 · 超过85%的资源 需积分: 48 128 下载量 91 浏览量
更新于2023-03-03
评论 3
收藏 1001KB PDF 举报
1、CentOS7下安装Elasticsearch7.4 2、SpringBoot版本2.1.8.RELEASE,集成Elasticsearch7.4实现创建索引、删除索引;添加输入
资源详情
资源评论
资源推荐
README.md 11/7/2019
1 / 29
1. Linux安装
1.1. 下载&安装
1.1.1. 环境需求
1.1.2. 下载
1.1.3. 安装
1.1.4. 修改配置文件
1.1.5. 启动&验证结果
1.2. 中文分词插件IK
1.2.1. 安装
1.2.2. ik_max_word和ik_smart
1.2.2.1. ik_smart分词
1.2.2.2. ik_max_word分词
1.3. 索引
1.3.1. 创建索引
1.3.1.1. 官方例子说明
1.3.1.2. 自定义索引
1.3.2. 查看索引
1.3.2.1. 全部索引
1.3.2.2. 条件查询
1.3.3. 查看索引分词器
1.3.4. 修改索引
1.3.5. 删除索引
1.4. 如何数据管理
1.4.1. 添加数据
1.4.2. 基础查询
1.4.2.1. 查询所有
1.4.2.2. 条件查询
1.4.3. 高级条件查询
1.4.3.1. 权重boost查询
1.4.3.2. 过滤coerce查询
1.4.3.2.1. 创建索引
1.4.3.2.2. 创建第一个数据
1.4.3.2.3. 创建第二个数据
1.4.3.3. copy_to
1.4.3.3.1. 定义索引
1.4.3.3.2. 新增数据
1.4.3.3.3. 查询数据
1.4.3.4. doc_values
1.4.3.5. dynamic
2. SpringBoot集成
2.1. POM
2.2. yml配置
2.3. 核心操作类
3. 实战
3.1. 创建索引
演示索引
README.md 11/7/2019
2 / 29
核心代码说明
4. 源码
1. Linux安装
1.1. 下载&安装
1.1.1. 环境需求
CentOs7
内存4G+
1.1.2. 下载
官方elasticsearch下载,下载elasticsearch,目前最新的稳定版本为 7.4.0 版本.
1.1.3. 安装
[root@localhost download]$ pwd
/data/download/
[root@localhost download]$ wget
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.0-linux-
x86_64.tar.gz
[root@localhost download]$ cd ../app/
[root@localhost app]$ mkdir elastic
[root@localhost app]$ useradd elastic -g dev
[root@localhost app]$ passwd elastic
[root@localhost app]$ chown -R elastic:dev elastic
[root@localhost app]$ su elastic
[elastic@localhost app]$ cd /elastic
[elastic@localhost elastic]$ cp ../../download/elasticsearch-7.4.0-linux-
x86_64.tar.gz .
[elastic@localhost elastic]$ tar -zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz
[elastic@localhost elastic]$ mv elasticsearch-7.4.0/ .
1.1.4. 修改配置文件
README.md 11/7/2019
3 / 29
路径config/elasticsearch.yml
-- 允许外部IP访问
network.host: 0.0.0.0
-- 把这个注释先放开
cluster.initial_master_nodes: ["node-1", "node-2"]
1.1.5. 启动&验证结果
启动
[elastic@localhost elastic]$ ./bin/elasticsearch
验证结果
Elastic会在默认9200端口运行,打开地址:http://192.168.147.132:9200/
1.2. 中文分词插件IK
1.2.1. 安装
ik插件地址: https://github.com/medcl/elasticsearch-analysis-ik,为了演示需要,这里选择wget方式。
下载
[root@localhost download]$ wget https://github.com/medcl/elasticsearch-analysis-
ik/releases/download/v7.4.0/elasticsearch-analysis-ik-7.4.0.zip
安装插件
README.md 11/7/2019
4 / 29
[elastic@localhost elastic]$ cd plugins
[elastic@localhost plugins]$ cd mkdir ik && cd ik
[elastic@localhost ik]$ cp ../../../download/elasticsearch-analysis-ik-7.4.0.zip .
[elastic@localhost ik]$ unzip elasticsearch-analysis-ik-7.4.0.zip
完成后重启es
验证分词器
使用crul命令,输入下面的URL地址,验证分词器是否成功。
[elastic@localhost elastic]$ curl -X GET -H "Content-Type: application/json"
"http://localhost:9200/_analyze?pretty=true" -d'{"text":"中华五千年华夏"}';
1.2.2. ik_max_word和ik_smart
ik_max_word: 将文本按最细粒度的组合来拆分,比如会将“中华五千年华夏”拆分为“五千年、五千、五
千年华、华夏、千年华夏”,总之是可能的组合;
ik_smart: 最粗粒度的拆分,比如会将“五千年华夏”拆分为“五千年、华夏”
不
添
加分
词
类
别
,
Elastic
对
于
汉
字
默
认
使
用
standard
只
是
将
汉
字
拆
分
成
一个个
的
汉
字
,
而
我
们
ik
则
更
加
的
智
能
,
下
面
通过
几
个
案
例
来
说
明
。
README.md 11/7/2019
5 / 29
1.2.2.1. ik_smart
分
词
在JSON格式中添加analyzer节点内容为ik_smart
[elastic@localhost elastic]$ curl -X GET -H "Content-Type: application/json"
"http://localhost:9200/_analyze?pretty=true" -d'{"text":"中华五千年华
夏","analyzer": "ik_smart"}';
1.2.2.2. ik_max_word
分
词
在JSON格式中添加analyzer节点内容为ik_max_word
[elastic@localhost elastic]$ curl -X GET -H "Content-Type: application/json"
"http://localhost:9200/_analyze?pretty=true" -d'{"text":"中华五千年华
夏","analyzer": "ik_max_word"}';
1.3. 索引
1.3.1. 创建索引
剩余28页未读,继续阅读
王老邪
- 粉丝: 111
- 资源: 64
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3