day74-ElasticSearch-分词- 自定义扩展词库

18 篇文章 0 订阅
12 篇文章 0 订阅

别人的文章链接,全一点

1.为了nginx容器配置,执行如下代码,若没有nginx容器会从远程拉取

docker run -p 80:80 --name nginx \
-v /mydata/nginx/html:/usr/share/nginx/html  \
-v /mydata/nginx/logs:/var/log/nginx \
-v /mydata/nginx/conf/:/etc//nginx \
-d nginx:1.10 POST _analyze

2.如下内存不太够,调大点

virtualbox上调整下

 3.访问http://192.168.56.10/出现如下说明nginx配置迁移成功

4.在nginx的html文件夹下添加index.html并添加 <h1>gulimall</h1> 再次访问会出现如下

 5.添加自定义分词文件

[root@localhost html]# mkdir es
[root@localhost html]# ls
es  index.html
[root@localhost html]# cd es
[root@localhost es]# ls
[root@localhost es]# vi fenci.txt
尚硅谷
乔碧萝

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~

我在输入中文的时候乱码了,所以在CRT中先调整了编码格式

6.修改配置上面自定义配置生效 

[root@localhost elasticsearch]# ls
config  data  plugins
[root@localhost elasticsearch]# cd plugins/
[root@localhost plugins]# ls
ik
[root@localhost plugins]# cd ik
[root@localhost ik]# ls
commons-codec-1.9.jar    config                               httpclient-4.5.2.jar  plugin-descriptor.properties
commons-logging-1.2.jar  elasticsearch-analysis-ik-7.4.2.jar  httpcore-4.4.4.jar    plugin-security.policy
[root@localhost ik]# cd config/
[root@localhost config]# ls
extra_main.dic         extra_single_word_full.dic      extra_stopword.dic  main.dic         quantifier.dic  suffix.dic
extra_single_word.dic  extra_single_word_low_freq.dic  IKAnalyzer.cfg.xml  preposition.dic  stopword.dic    surname.dic
[root@localhost config]# vi IKAnalyzer.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
        <comment>IK Analyzer 扩展配置</comment>
        <!--用户可以在这里配置自己的扩展字典 -->
        <entry key="ext_dict"></entry>
         <!--用户可以在这里配置自己的扩展停止词字典-->
        <entry key="ext_stopwords"></entry>
        <!--用户可以在这里配置远程扩展字典 -->
         <entry key="remote_ext_dict">http://192.168.56.10/es/fenci.txt</entry>
        <!--用户可以在这里配置远程扩展停止词字典-->
        <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
</properties>
~
~
~

7.重启es并设置自启动

[root@localhost config]# cd /
[root@localhost /]# docker start elasticsearch
elasticsearch
[root@localhost /]# docker update elasticsearch --restart=always

8.测试,发现我们新添加的俩词汇:乔碧萝,尚硅谷生效了,成功分词

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我才是真的封不觉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值