Elasticsearch学习整理


Elasticsearch学习整理:

1、下载Elasticsearch:   https://www.elastic.co/
目前下载的版本为:7.6.1 mac版
下载后解压:tar -vxf ElasticsearchXXXX
启动ES:   lx@LXdeMacBook-Pro elasticsearch-7.6.1 % sh ./bin/elasticsearch

启动报错一:
./bin/elasticsearch-env: line 116: syntax error near unexpected token `
解决方法:elasticsearch-env文件中第116行修改为:done

启动报错二:
This could be due to running on an unsupported OS or distribution, missing OS libraries, or a problem with the temp directory.
解决方法:
   进入config目录下在elasticsearch.yml添加一条配置:xpack.ml.enabled: false

ES访问地址:http://localhost:9200

2、下载kibana
     https://www.elastic.co/
   kibana可进行可视化操作ES
   解压后,启动:
  lx@LXdeMacBook-Pro kibana-7.6.1-darwin-x86_64 % sh ./bin/kibana
    kibana访问地址:http://localhost:5601/

   3、下载中文分词器elasticserch-analysis-ik
   https://github.com/medcl/elasticsearch-analysis-ik/releases
   elasticserch-analysis-ik的版本号需与Elasticsearch版本匹配下载。
   把下载的包解压后,在/elasticsearch-7.6.1/plugins文件下建一个文件夹ik,然后把解压的所有内容复制到ik下面。然后重新启动ES,这时可通过kibana进行查操作查看效果。

GET _analyze
{
  "analyzer": "ik_smart",
  "text": "我是中国人"
}
{
  "tokens" : [
    {
      "token" : "我",
      "start_offset" : 0,
      "end_offset" : 1,
      "type" : "CN_CHAR",
      "position" : 0
    },
    {
      "token" : "是",
      "start_offset" : 1,
      "end_offset" : 2,
      "type" : "CN_CHAR",
      "position" : 1
    },
    {
      "token" : "中国人",
      "start_offset" : 2,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 2
    }
  ]
}

  

GET _analyze
{
  "analyzer": "ik_max_word",
  "text": "我是中国人"
}

 




相关推荐