Elastic Search配置Nginx提供分词器所需的自定义词库改善分词效果------Elastic Search

POST _analyze
{
  "analyzer": "ik_max_word",
  "text": "巧碧螺殿下"
}

POST _analyze
{
  "analyzer": "ik_max_word",
  "text": "巧碧螺殿下"
}

{
  "tokens" : [
    {
      "token" : "巧碧螺",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "殿下",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 1
    }
  ]
}

 {
  "tokens" : [
    {
      "token" : "巧碧螺",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "殿下",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 1
    }
  ]
}

[root@localhost es]# pwd
/mydata/nginx/html/es
[root@localhost es]# cd /mydata
[root@localhost mydata]# cd elasticsearch/
[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 
[root@localhost config]# docker restart elasticsearch
Error response from daemon: No such container: elasticsearch
[root@localhost config]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                                                                                                                      NAMES
4f19fab031f0   nginx:1.10            "nginx -g 'daemon of…"   16 minutes ago   Up 16 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp                                                                                                 nginx
1b6793c54215   elasticsearch:7.4.2   "/usr/local/bin/dock…"   31 minutes ago   Up 31 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                                       elasticsearch-p
5a879124a74b   kibana:7.4.2          "/usr/local/bin/dumb…"   7 days ago       Up 37 minutes   0.0.0.0:5601->5601/tcp, :::5601->5601/tcp                                                                                                  kibana
25a5439186fa   d445c0adc9a5          "docker-entrypoint.s…"   2 months ago     Up 37 minutes   4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:5673->5672/tcp, :::5673->5672/tcp   rabbit
db61879bdaf3   redis                 "docker-entrypoint.s…"   4 months ago     Up 37 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                                                                  redis
8b875b01624e   mysql:5.7             "docker-entrypoint.s…"   4 months ago     Up 37 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                       mysql
[root@localhost config]# docker restart 1b6793c54215
1b6793c54215
[root@localhost config]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1494         900         177          30         415         408
Swap:          2047         182        1865

 [root@localhost es]# pwd
/mydata/nginx/html/es
[root@localhost es]# cd /mydata
[root@localhost mydata]# cd elasticsearch/
[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 
[root@localhost config]# docker restart elasticsearch
Error response from daemon: No such container: elasticsearch
[root@localhost config]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                                                                                                                      NAMES
4f19fab031f0   nginx:1.10            "nginx -g 'daemon of…"   16 minutes ago   Up 16 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp                                                                                                 nginx
1b6793c54215   elasticsearch:7.4.2   "/usr/local/bin/dock…"   31 minutes ago   Up 31 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                                       elasticsearch-p
5a879124a74b   kibana:7.4.2          "/usr/local/bin/dumb…"   7 days ago       Up 37 minutes   0.0.0.0:5601->5601/tcp, :::5601->5601/tcp                                                                                                  kibana
25a5439186fa   d445c0adc9a5          "docker-entrypoint.s…"   2 months ago     Up 37 minutes   4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:5673->5672/tcp, :::5673->5672/tcp   rabbit
db61879bdaf3   redis                 "docker-entrypoint.s…"   4 months ago     Up 37 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                                                                  redis
8b875b01624e   mysql:5.7             "docker-entrypoint.s…"   4 months ago     Up 37 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                       mysql
[root@localhost config]# docker restart 1b6793c54215
1b6793c54215
[root@localhost config]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1494         900         177          30         415         408
Swap:          2047         182        1865

[root@localhost nginx]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED       SIZE
redis           latest    7614ae9453d1   2 years ago   113MB
mysql           5.7       c20987f18b13   2 years ago   448MB
kibana          7.4.2     230d3ded1abc   4 years ago   1.1GB
elasticsearch   7.4.2     b1179d41a7b4   4 years ago   855MB
nginx           1.10      0346349a1a64   7 years ago   182MB
[root@localhost nginx]# cd ../
[root@localhost mydata]# mv nginx conf
[root@localhost mydata]# ls
conf  elasticsearch  mysql  redis
[root@localhost mydata]# mkdir nginx
[root@localhost mydata]# mv conf nginx/
[root@localhost mydata]# ls
elasticsearch  mysql  nginx  redis
[root@localhost mydata]# cd nginx/
[root@localhost nginx]# ls
conf
[root@localhost 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
4f19fab031f08f46c1444ff38452d41aed589422692085c2c8f3ce2110d52149
[root@localhost nginx]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                                                                                                                      NAMES
4f19fab031f0   nginx:1.10            "nginx -g 'daemon of…"   6 seconds ago    Up 4 seconds    0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp                                                                                                 nginx
1b6793c54215   elasticsearch:7.4.2   "/usr/local/bin/dock…"   15 minutes ago   Up 15 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                                       elasticsearch-p
5a879124a74b   kibana:7.4.2          "/usr/local/bin/dumb…"   7 days ago       Up 20 minutes   0.0.0.0:5601->5601/tcp, :::5601->5601/tcp                                                                                                  kibana
25a5439186fa   d445c0adc9a5          "docker-entrypoint.s…"   2 months ago     Up 20 minutes   4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:5673->5672/tcp, :::5673->5672/tcp   rabbit
db61879bdaf3   redis                 "docker-entrypoint.s…"   4 months ago     Up 20 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                                                                  redis
8b875b01624e   mysql:5.7             "docker-entrypoint.s…"   4 months ago     Up 20 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                       mysql
[root@localhost nginx]# ls
conf  html  logs
[root@localhost nginx]# cd html/
[root@localhost html]# ls
[root@localhost html]# vi index.html
[root@localhost html]# vi index.html
[root@localhost html]# vi index.html
[root@localhost html]# pwd
/mydata/nginx/html
[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
[root@localhost es]# cat fenci.txt

 [root@localhost nginx]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED       SIZE
redis           latest    7614ae9453d1   2 years ago   113MB
mysql           5.7       c20987f18b13   2 years ago   448MB
kibana          7.4.2     230d3ded1abc   4 years ago   1.1GB
elasticsearch   7.4.2     b1179d41a7b4   4 years ago   855MB
nginx           1.10      0346349a1a64   7 years ago   182MB
[root@localhost nginx]# cd ../
[root@localhost mydata]# mv nginx conf
[root@localhost mydata]# ls
conf  elasticsearch  mysql  redis
[root@localhost mydata]# mkdir nginx
[root@localhost mydata]# mv conf nginx/
[root@localhost mydata]# ls
elasticsearch  mysql  nginx  redis
[root@localhost mydata]# cd nginx/
[root@localhost nginx]# ls
conf
[root@localhost 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
4f19fab031f08f46c1444ff38452d41aed589422692085c2c8f3ce2110d52149
[root@localhost nginx]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                                                                                                                      NAMES
4f19fab031f0   nginx:1.10            "nginx -g 'daemon of…"   6 seconds ago    Up 4 seconds    0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp                                                                                                 nginx
1b6793c54215   elasticsearch:7.4.2   "/usr/local/bin/dock…"   15 minutes ago   Up 15 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                                       elasticsearch-p
5a879124a74b   kibana:7.4.2          "/usr/local/bin/dumb…"   7 days ago       Up 20 minutes   0.0.0.0:5601->5601/tcp, :::5601->5601/tcp                                                                                                  kibana
25a5439186fa   d445c0adc9a5          "docker-entrypoint.s…"   2 months ago     Up 20 minutes   4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:5673->5672/tcp, :::5673->5672/tcp   rabbit
db61879bdaf3   redis                 "docker-entrypoint.s…"   4 months ago     Up 20 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                                                                  redis
8b875b01624e   mysql:5.7             "docker-entrypoint.s…"   4 months ago     Up 20 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                       mysql
[root@localhost nginx]# ls
conf  html  logs
[root@localhost nginx]# cd html/
[root@localhost html]# ls
[root@localhost html]# vi index.html
[root@localhost html]# vi index.html
[root@localhost html]# vi index.html
[root@localhost html]# pwd
/mydata/nginx/html
[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
[root@localhost es]# cat fenci.txt

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值