ElasticSearch IK word divider quick to use

Install IK word divider

1. Assign a pseudo terminal

My ElasticSearch was installed using Docker, so I assigned a pseudo-terminal to the container first. Docker execit container ID /bin/bash docker execit container ID /bin/bash

2. Install the elasticSearch -plugin

Go to the plugins folder and run the following command: 7.12.0 needs to be changed to your ES version number

../bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.0/elasticsearch-analysis-ik-7.12.0.zip
Copy the code

3. Restart elasticSearch

Docker restart Container ID

4. Frequently Asked Questions

(1)java.lang.IllegalStateException

Perform elasticsearch – plugin install, appeared Failed installing and Java. Lang. An IllegalStateException

I already have a folder called IK in my plugins/ directory. In the spirit of trying, delete the folder named IK and try again

../bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.0/elasticsearch-analysis-ik-7.12.0.zip
Copy the code

Successful installation

Two, IK participle principle

(placeholder, wait for time to read the source code to supplement)

Ik_smart and IK_MAX_word

GET _analyze? Pretty {" Analyzer ": "ik_smart", "text": "Unlike me, only distressed pigeon pigeon"}Copy the code

GET _analyze? Pretty {"analyzer": "ik_max_word", "text": "Unlike me, only distressed pigeon pigeon"}Copy the code

conclusion

  • _analyzer Is the word analyzer that builds the index. Max_word is used for the index
  • Search_analyzer Searches for the word. Smart is used for the query

The original link

This article is the original content of Aliyun and shall not be reproduced without permission.