elasticsearch 支持中英文搜索和混合搜索
Posted yuwensong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch 支持中英文搜索和混合搜索相关的知识,希望对你有一定的参考价值。
环境: ubuntu16.04
安装: elasticsearch 5.22
1. 第一步,安装java
apt-get install default-jre
apt-get install default-jdk
2.第二步,安装elasticsearch. 5.22
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.deb
dpkg -i elasticsearch-5.2.2.deb
3.启动服务
systemctl daemon-reload
systemctl enable elasticsearch
systemctl restart elasticsearch
碰到问题:
[2018-07-02 18:36:32,700][INFO ][node ] [Captain Fate] version[1.7.3], pid[25545], build[NA/NA]
[2018-07-02 18:36:32,701][INFO ][node ] [Captain Fate] initializing ...
[2018-07-02 18:36:32,900][INFO ][plugins ] [Captain Fate] loaded [], sites []
[2018-07-02 18:36:32,930][INFO ][env ] [Captain Fate] using [1] data paths, mounts [[/ (/dev/vda1)]], net usable_space [27gb], net total_space [39.2gb], types [ext4]
[2018-07-02 18:36:35,634][WARN ][common.network ] failed to resolve local host, fallback to loopback
java.net.UnknownHostException: iZhp3ig1mh8lh6acp6sx0xZ: iZhp3ig1mh8lh6acp6sx0xZ: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at org.elasticsearch.common.network.NetworkUtils.<clinit>(NetworkUtils.java:55)
at org.elasticsearch.http.netty.NettyHttpServerTransport.<init>(NettyHttpServerTransport.java:165)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
修改etc/hosts文件,加上你自己的hostname里面的值
127.0.0.1 localhost iZhp3ig1mh8lh6acp6sx0xZ
4.验证是否成功
curl -XGET "http://localhost:9200"
5.注意的几点:
a.新建用户elasticsearch
useradd elasitcsearch
b.让上面的用户拥有目录:/usr/share/elasticsearch 的权限
chown elasitcsearch:elasitcsearch /usr/share/elasticsearch
chown -R 777 /usr/share/elasticsearch
6.添加支持中文分词的插件等,所有插件,必须和elasticsearch版本一致,下载解压到/usr/share/elasticsearch/plugins目录下面,名字如下=命名:
7.启动的时候可以切换到目录/usr/share/elasticsearch/bin/ . 直接执行./elasticsearch 就可以进行启动了
需要的插件地址都可以在这里找到:https://github.com/medcl
下载如下
elasticsearch-5.2.2.deb elasticsearch-analysis-stconvert-5.2.2.zip
elasticsearch-analysis-ik-5.2.2.zip kibana-5.2.2-amd64.deb
以上是关于elasticsearch 支持中英文搜索和混合搜索的主要内容,如果未能解决你的问题,请参考以下文章
以图搜图 最佳实践阿里云 Elasticsearch 向量检索4步搭建“以图搜图”搜索引擎,