一.简介
Elasticsearch是一个基于Lucence的搜索服务器。它提供了一个分布式的搜索引擎,基于restful web接口。广泛应用于云计算中,能够实时搜索,具有稳定,可靠,快速的特点。
二.为啥要学习Elasticsearch?
它其实也是一种数据库的优化方案,它的强大之处在于模糊查询。如果是普通数据库查询 like%xxxx%,其实是不走索引的。只要你的数据库的量很大,你的查询肯定会是秒级别的。(es搜索速度很快)
用户输入其实没那么精确或者打错,Elasticsearch却能返回用户想要的结果。(es匹配相关性较高)
还有一点是我想在目前参与的资产监控平台加一个es搜索功能,公司资产太多,资产查询模块速度较慢,值得优化。
三.下载
- Elasticsearch服务端
https://www.elastic.co/cn/downloads/elasticsearchhttp://127.0.0.1:9200/
- Elasticsearch客户端
- https://github.com/mobz/elasticsearch-head/- 下载后安装依赖 npm install、npm run start;- http://127.0.0.1:9100/- 由于ES进程跟客户端进程端口号不同,存在跨域问题,所以在- - ES配置下跨域问题(elasticsearch.yml)- 跨域配置: http.cors.enabled: true http.cors.allow-origin:
- 安装Kibana
- https://www.elastic.co/cn/downloads/kibana- http://localhost:5601/
- 安装IK分词器插件
- https://github.com/medcl/elasticsearch-analysis-ik/ - 下载解压后将目录拷贝到Elasticsearch根目录的plugins目录中
![7204f37fb530cc7d079a525416ecd9e3.png](https://i-blog.csdnimg.cn/blog_migrate/b20c6f1ba7f6a95f4e9d8cc7072066ee.jpeg)
![29e6a963385585bf9c5c6f7e6e568d63.png](https://i-blog.csdnimg.cn/blog_migrate/29dbad349ca80e60c01612f582e4b126.jpeg)
四.集群状态查看
- 查看集群健康状态
GET /_cat/health?v
- 查看节点状态
GET