• elasticsearch IK中文分词


    1. analysis-ik安装


    1). 从 https://github.com/medcl/elasticsearch-analysis-ik ,下载 elasticsearch-analysis-ik-master.zip

     
    2). 解压后,
         cd  elasticsearch-analysis-ik-master
         /usr/local/maven/bin/mvn package                
         .... wait  5-6分钟
        
        编译成功后,
        拿到target/releases/下的zip包,上传到服务器上
        上config目录的ik文件夹到服务器上
     
    3). 安装插件
        /usr/share/elasticsearch/bin/plugin -i analysis-ik -u file:///soft/elasticsearch-analysis-ik-1.3.0.zip (本地安装)
        /usr/share/elasticsearch/bin/plugin -i analysis-ik ftp://10.104.16.43/es/analysis-ik/elasticsearch-analysis-ik-1.3.0.zip (内网安装)
        scp -r ./ik $ip:/etc/elasticsearch/
        echo 'index.analysis.analyzer.ik.type : "ik"' >> /etc/elasticsearch/elasticsearch.yml
     
    4).重启集群
       
     
    2. analysis-ik测试

    导入测试数据
    1. [root@VM_16_43_centos analysis-ik]# cat iktest.sh
    2. #1.creat a index
    3. curl -XPUT http://localhost:9200/iktest
    4. #2.create a mapping
    5. curl -XPOST http://localhost:9200/iktest/fulltext/_mapping -d'
    6. {
    7. "fulltext": {
    8. "_all": {
    9. "indexAnalyzer": "ik",
    10. "searchAnalyzer": "ik",
    11. "term_vector": "no",
    12. "store": "false"
    13. },
    14. "properties": {
    15. "content": {
    16. "type": "string",
    17. "store": "no",
    18. "term_vector": "with_positions_offsets",
    19. "indexAnalyzer": "ik",
    20. "searchAnalyzer": "ik",
    21. "include_in_all": "true",
    22. "boost": 8
    23. }
    24. }
    25. }
    26. }'
    27. #3.iktest index some docs
    28. curl -XPOST http://localhost:9200/iktest/fulltext/1-d'
    29. {"content":"美国留给伊拉克的是个烂摊子吗"}
    30. '
    31. curl -XPOST http://localhost:9200/iktest/fulltext/2-d'
    32. {"content":"公安部:各地校车将享最高路权"}
    33. '
    34. curl -XPOST http://localhost:9200/iktest/fulltext/3-d'
    35. {"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
    36. '
    37. curl -XPOST http://localhost:9200/iktest/fulltext/4-d'
    38. {"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
    39. '
    1. [root@VM_16_43_centos analysis-ik]# sh iktest.sh
    2. {"acknowledged":true}
    3. {"acknowledged":true}
    4. {"_index":"iktest","_type":"fulltext","_id":"1","_version":1,"created":true}
    5. {"_index":"iktest","_type":"fulltext","_id":"2","_version":1,"created":true}
    6. {"_index":"iktest","_type":"fulltext","_id":"3","_version":1,"created":true}
    7. {"_index":"iktest","_type":"fulltext","_id":"4","_version":1,"created":true}
    查询数据
    1)搜索“男子”
     
    2) 搜索“公安”





  • 相关阅读:
    Git 学习笔记(W,I,P)
    DirectX API 编程起步 #01 项目设置
    #1004 Let the Balloon Rise
    #1003 Max Sum
    人生的第一个博客(●'◡'●)ノ♥--开博典礼
    2053——switch game
    在Activity间传递数据的四种方法及返回结果
    安卓学习第38课——ProgressDialog
    安卓学习第37课——DatePickerDialog、TimePickerDialog
    安卓学习第36课——PopupWindow
  • 原文地址:https://www.cnblogs.com/51runsky/p/4665793.html
Copyright © 2020-2023  润新知