zoukankan      html  css  js  c++  java
  • solrcloud配置中文分词器ik

    无论是solr还是luncene,都对中文分词不太好,所以我们一般索引中文的话需要使用ik中文分词器。

    三台机器(192.168.1.236,192.168.1.237,192.168.1.238)已经安装好了solrcloud

    我安装的是solr5.5使用的是ik是IKAnalyzer2012FF_u2.rar

    下载IKAnalyzer2012FF_u2.rar下载地址:http://download.csdn.net/detail/sunqingzhong44/9835849

    一下步骤三台机器都要操作

    下载后进行进行解压

    复制IKAnalyzer2012FF_u2.jar到tomcat/weapps/solr/WEB-INF/lib/下

    复制ext.dic,IKAnalyzer.cfg.xml到tomcat/weapps/solr/WEB-INF/classes下

    一下操作只在一台机器上操作即可

    下载collection在zookeeper上所对应的schema.xml配置文件

    [plain] view plain copy
     
    1. /usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd getfile /configs/mycollection3  
    [plain] view plain copy
     
    1. /schema.xml schema.xml  

    /configs/mycollection3/schema.xml #这是zookeeper上的配置文件
    schema.xml #这是下载后的文件

    修改下载的schema.xml文件

    在最后增加:

    [html] view plain copy
     
    1. <fieldType name="text_ik" class="solr.TextField">  
    2.        <analyzer type="index" useSmart="false" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer>  
    3.        <analyzer type="query" useSmart="true"  isMaxWordLength="true" class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer>  
    4.    </fieldType>  

    可以在定义域的时候使用ik分词器:

    [html] view plain copy
     
    1. <field name="name" type="text_ik" indexed="true" stored="true"/>  
    2.   <field name="text" type="text_ik" indexed="true" stored="true"/>  


    上传修改好的配置文件schema.xml到zookeeper上

    [html] view plain copy
     
    1. /usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd putfile /configs/mycollection2  
    [html] view plain copy
     
    1. /schema.xml  schema.xml  


    /configs/mycollection3/schema.xml #这是zookeeper上的配置文件
    schema.xml #这是修改后的文件

    重新启动tomcat后测试:

     

  • 相关阅读:
    docker swarm使用keepalived+haproxy搭建基于percona-xtradb-cluster方案的高可用mysql集群
    docker搭建基于percona-xtradb-cluster方案的mysql集群
    flask实现基于elasticsearch的关键词搜索建议
    tcp === udp
    re 模块===正则表达式
    模块===包
    析构方法====
    python===属性--类方法
    python====接口类 抽象类===19
    python==继承===18
  • 原文地址:https://www.cnblogs.com/cxhfuujust/p/7735733.html
Copyright © 2011-2022 走看看