elasticsearch 7.1.0 安装中文分词

2022年1月19日 820点热度 0人点赞 0条评论

1 elasticseach plugin介绍

1 elastic 插件

1.1 查询插件命令

bin/elasticsearch-plugin list

http://localhost:9200/_cat/plugins

1.2 安装插件

bin/elasticsearch-plugin install plugin-name

1.3 插件的配置目录

~/elasticsearch安装目录/plugins

1.4 常用插件介绍

elasticsearch-head插件,中文分词插件

2 中文分词插件安装

拼音分词器:https://github.com/medcl/elasticsearch-analysis-pinyin

中文分词器:https://github.com/medcl/elasticsearch-analysis-ik

下载自己对应版本的插件

  • Elasticsearch 7.1.1
  • elasticsearch-analysis-ik 7.1.1
  • elasticsearch-analysis-pinyin 7.1.1
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip
 
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.1.1/elasticsearch-analysis-pinyin-7.1.1.zip
例如:
 ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.0/elasticsearch-analysis-ik-7.1.0.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.0/elasticsearch-analysis-ik-7.1.0.zip
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

有安装完成后在ES的配置文件config/elasticsearch.yml中增加ik的配置,在最后增加:

index:
  analysis:                   
    analyzer:      
      ik:
          alias: [ik_analyzer]
          type: org.elasticsearch.index.analysis.IkAnalyzerProvider
      ik_max_word:
          type: ik
          use_smart: false
      ik_smart:
          type: ik
          use_smart: true

最后启动时会报错:节点设置不能包含任何索引级别设置

也就是说报错是因为 在elasticsearce.yml文件中对索引进行了配置 , 删除相应的索引配置即可.

从 elasticsearch 5.x index level settings can NOT be set on the nodes 。

Found index level settings on node level configuration.

Since elasticsearch 5.x index level settings can NOT be set on the nodes 
configuration like the elasticsearch.yaml, in system properties or command line 
arguments.In order to upgrade all indices the settings must be updated via the 
/${index}/_settings API. Unless all settings are dynamic all indices must be closed 
in order to apply the upgradeIndices created in the future should use index templates 
to set default values. 

Please ensure all required values are updated on all indices by executing: 

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
  "index.analysis.analyzer.ik.alias[0]" : "ik_analyzer",
  "index.analysis.analyzer.ik.type" : "org.elasticsearch.index.analysis.IkAnalyzerProvider",
  "index.analysis.analyzer.ik_max_word.type" : "ik",
  "index.analysis.analyzer.ik_max_word.use_smart" : "false",
  "index.analysis.analyzer.ik_smart.type" : "ik",
  "index.analysis.analyzer.ik_smart.use_smart" : "true"
}'
*************************************************************************************

[2022-01-19T10:37:01,640][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [hhbdeMacBook-Pro.local] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.1.0.jar:7.1.0]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.1.0.jar:7.1.0]
Caused by: java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:142) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.node.Node.<init>(Node.java:343) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:211) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:211) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.1.0.jar:7.1.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.0.jar:7.1.0]
	... 6 more

管理员

这个人很懒,什么都没留下

文章评论