Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use es word Segmentation plug-in hanlp for elasticsearch based on hanlp

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Based on hanlp es participle plug-in hanlp for elasticsearch how to use, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Elasticsearch-analysis-hanlp plug-in address: https://github.com/pengcong90/elasticsearch-analysis-hanlp

Elasticsearch

Default participle

Output:

IK:

Output:

Hanlp:

Output:

Ik participle does not divide words according to the meaning of the sentence. Hanlp can segment words correctly according to the meaning of the sentence.

Installation steps: 1. Enter https://github.com/pengcong90/elasticsearch-analysis-hanlp, download the plug-in and decompress it to the plugins directory of es, modify the hanlp.properties file under analysis-hanlp directory, modify the properties of root, and the value is the address of the data directory under analysis-hanlp.

2. Modify the jvm.options file in the es config directory and add it on the last line

-Djava.security.policy=../plugins/analysis-hanlp/plugin-security.policy

Restart es

GET / _ analyze?analyzer=hanlp-index&pretty=true {"text": "Cecilia Cheung Cake Shop"} Test whether the installation is successful

Analyzer has hanlp-index (index mode) and hanlp-smart (smart mode).

Custom Dictionary:

Modify my dictionary .txt file under plugins/analysis-hanlp/data/dictionary/custom

The format follows the frequency of [word] [part of speech A] [A]

Delete the CustomDictionary.txt.bin file in the same directory after modification

Restart the es service

Currently, only 5.x version is supported

Note that in the 5.5.1 version of es under mac, delete the hidden .DS _ Store file in plugins, otherwise the startup will report an error.

After reading the above, have you mastered how to use the hanlp-based es participle plug-in hanlp for elasticsearch? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report