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"
elasticsearch 支持中英文搜索和混合搜索

 

5.注意的几点:

a.新建用户elasticsearch 

useradd elasitcsearch

b.让上面的用户拥有目录:/usr/share/elasticsearch 的权限

chown elasitcsearch:elasitcsearch /usr/share/elasticsearch

chown -R 777 /usr/share/elasticsearch

 sudo chown -R elsearch:elsearch /etc/elasticsearch

sudo chmod -R 775 /etc/elasticsearch/

 

6.添加支持中文分词的插件等,所有插件,必须和elasticsearch版本一致,下载解压到/usr/share/elasticsearch/plugins目录下面,名字如下=命名:

elasticsearch 支持中英文搜索和混合搜索

 

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

 

问题:

1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配

  1. # vim config/jvm.options
  2. -Xms2g
  3. -Xmx2g
修改为
  1. -Xms512m
  2. -Xmx512m

2.Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchF

ileException: /usr/share/elasticsearch/config

解决方法:cp -R /etc/elasticsearch/* ./config/

 


Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config

上一篇:Android小技巧之来不及解释了快上车--EventBus3


下一篇:Android初级进阶之自定义时钟(一)