当下最流行的全文搜索引擎。告诉你今后搜索不能再想着去查DB了,至少面试不能!

安装

  • Java 8 环境
    去官网下载安装包
    https://www.elastic.co/cn/elasticsearch/
    解压后启动
    ./bin/elasticsearch

查看链接是否成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~ curl localhost:9200
{
"name" : "YBPHP.local",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "p5IcmZiLTVaLqbIaYR9zwA",
"version" : {
"number" : "7.7.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "ad56dce891c901b494bb1ee393f12dfff472a423",
"build_date" : "2020-05-28T16:30:01.040088Z",
"build_snapshot" : false,
"lucene_version" : "8.5.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
安装线上管理工具(elasticsearch-head)
1
2
3
4
5
git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
open http://localhost:9100/
  • 如果打开发现连接不上elastic,需修改一下elastic的配置(允许跨域)
    1
    2
    3
    4
    vi config/elasticsearch.yml
    #在文件末尾加上如下配置
    http.cors.enabled: true
    http.cors.allow-origin: "*"

连接成功如下:
首页