1、下载并安装Elasticsearch服务
1.1、安装Java JDK:在安装Elasticsearch引擎之前,必须安装ES需要的软件环境,安装Java JDK和配置JAVA_HOME环境变量,Elasticsearch7.0以上版本需要安装jdk11以上版本,Elasticsearch5.0以上版本需要安装jdk1.8,其他版本安装jdk1.7即可。安装jdk后最好禁用Java JDK的自动更新。
1.2、从官方下载中心:ElasticSearch Download下载ElasticSearch安装包并解压 地址:https://www.elastic.co/cn/downloads/elasticsearch。
1.3、开启ElasticSearch 服务:Run bin/elasticsearch
(or bin\elasticsearch.bat
on Windows)
windows 进入E:\elasticsearch-6.3.2\bin目录,双击执行 elasticsearch.bat,该脚本文件执行 ElasticSearch 安装程序;
1.4、稍等片刻,打开浏览器,输入 http://localhost:9200 ,显式以下画面,说明ES安装成功。
2、安装Elasticsearch head插件
为了便于管理ES,本文使用head插件,这是最初级的管理工具,在浏览器中显示ES集群,索引等信息,十分好用。
2.1、安装Elasticsearch head:
下载地址:elasticsearch-head 地址:https://github.com/mobz/elasticsearch-head,点击clone or download按钮,点击download zip进行下载。
2.2、下载完毕后解压到除elasticsearch安装路径上的任意路径上。
3、安装IK
ik分词器:https://github.com/medcl/elasticsearch-analysis-ik
IK分词器有两种分词模式:ik_max_word和ik_smart模式。
1、ik_max_word
会将文本做最细粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为“中华人民共和国、中华人民、中华、华人、人民共和国、人民、共和国、大会堂、大会、会堂等词语。
2、ik_smart
会做最粗粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为中华人民共和国、人民大会堂。
测试两种分词模式的效果:
发送:post localhost:9200/_analyze
测试ik_max_word
{“text”:“中华人民共和国人民大会堂”,“analyzer”:“ik_max_word” }
测试ik_smart
{“text”:“中华人民共和国人民大会堂”,“analyzer”:“ik_smart” }
Analyzer: ik_smart
, ik_max_word
, Tokenizer: ik_smart
, ik_max_word
Versions
IK version | ES version |
---|---|
master | 7.x -> master |
6.x | 6.x |
5.x | 5.x |
1.10.6 | 2.4.6 |
1.9.5 | 2.3.5 |
1.8.1 | 2.2.1 |
1.7.0 | 2.1.1 |
1.5.0 | 2.0.0 |
1.2.6 | 1.0.0 |
1.2.5 | 0.90.x |
1.1.3 | 0.20.x |
1.0.0 | 0.16.2 -> 0.19.0 |
1.download or compile
-
optional 1 - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/releases
create plugin folder
cd your-es-root/plugins/ && mkdir ik
unzip plugin to folder
your-es-root/plugins/ik
-
optional 2 - use elasticsearch-plugin to install ( supported from version v5.5.1 ):
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.0/elasticsearch-analysis-ik-6.3.0.zip
NOTE: replace
6.3.0
to your own elasticsearch version
2.restart elasticsearch