ES的安装以及配置+ik分词
Elasticsearch (ES) 的安装和配置通常依赖于操作系统。以下是在Linux上安装Elasticsearch的步骤,并配置ik分词器。
- 导入Elasticsearch公钥:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- 添加Elasticsearch到APT仓库列表:
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
- 更新包索引并安装Elasticsearch:
sudo apt-get update && sudo apt-get install elasticsearch
- 启动并使Elasticsearch随系统启动:
sudo systemctl start elasticsearch.service
sudo systemctl enable elasticsearch.service
- 验证Elasticsearch是否正在运行:
curl -X GET "localhost:9200/"
安装ik分词器:
- 下载并解压ik分词器的压缩包:
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
unzip elasticsearch-analysis-ik-7.7.0.zip
- 将ik分词器插件复制到Elasticsearch的插件目录:
sudo cp -r elasticsearch-analysis-ik-7.7.0/ /usr/share/elasticsearch/plugins/ik
- 重启Elasticsearch服务以使ik分词器生效:
sudo systemctl restart elasticsearch.service
测试ik分词器:
curl -X POST "localhost:9200/_analyze?pretty" -H 'Content-Type: application/json' -d'
{
"text": "我爱编程语言",
"tokenizer": "ik_max_word"
}'
以上步骤适用于Elasticsearch 7.x版本。如果您使用的是其他版本,请确保下载与您的ES版本相匹配的ik分词器版本。
评论已关闭