zoukankan      html  css  js  c++  java
  • Solr6.6 配置中文分词库mmseg4j

      1、准备

          首先安装solr:参照搜索引擎Solr-6.6.0搭建,如果版本高于6,可能会不支持,需要改mmseg4j包

          mmseg4j包下载: mmseg4j-solr-2.3.0-with-mmseg4j-core.zip 或 https://pan.baidu.com/s/1dD7qMFf#list/path=%2F

          开源地址:https://github.com/chenlb/mmseg4j-solr

          解压下载的压缩包mmseg4j-solr-2.3.0-with-mmseg4j-core.zip,得到mmseg4j-core-1.10.0.jarmmseg4j-solr-2.3.0.jar把这两个文件拷贝到tomcat的webappssolrWEB-INFlib路径下

          

      2、建立core

         建立mycore,具体参见搜索引擎Solr-6.6.0搭建的“四、Solr6.6.0环境搭建”部分。

      3、修改配置文件

         修改mycore/conf的配置文件managed-schema,增加以下内容:

    <!-- mmseg4j fieldType-->
        <fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
              <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" />     
            </analyzer>  
        </fieldType>

        启动重新启动tomcat,在浏览器中输入http://localhost:8080/solr/index.html,

        在管理界面选择分析,输入“我是中国人”  类型选择上面的三种的一种进行分析如下:

        

       4、直接启动solr自带的Jetty,不用tomcat

          进入solr6.6的bin目录,启动solr,通过命令建立core

          solr create -c mycore

           

          这样在solr-6.6.0serversolr目录下生成mycore

          

        

        修改mycoreconf文件夹下的配置文件managed-schema,在最后新增一项内容

        

    <!-- mmseg4j fieldType-->
        <fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
              <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" />     
            </analyzer>  
        </fieldType>

        

         把mmseg4j-core-1.10.0.jarmmseg4j-solr-2.3.0.jar拷贝到solr-6.6.0serversolr-webappwebappWEB-INFlib文件夹下

         

        执行命令solr stop -all

        重新启动solr

        

         重新打开浏览器输入:http://localhost:8983/solr/#/

        

         或者直接修改solr-6.6.0serversolrconfigsetsdata_driven_schema_configsconf文件夹下的配置文件managed-schema,在最后新增以下内容:

    <!-- mmseg4j fieldType-->
        <fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
                <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" />  
            </analyzer>  
        </fieldType>  
        <fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >  
            <analyzer>  
              <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" />     
            </analyzer>  
        </fieldType>

        这样在新建core的时候就不用每次都修改单个core的managed-schema配置文件了

        

      参照资料:http://blog.csdn.net/jiangchao858/article/details/53026374

  • 相关阅读:
    ecos 编译时无法找到 tclConfig.sh 和 tkConfig.sh
    gcc 的宏替换 __stringify
    CentOS 静态IP配置
    光照
    CUnit 安装
    git push not configured with USE_CURL_MULTI
    在VC中用FreeImage显示图片的简单方法
    vanilla kernel
    Eclipse CDT 对 Doxygen 型注释的支持
    己所不欲,人欲取之
  • 原文地址:https://www.cnblogs.com/shaosks/p/7843218.html
Copyright © 2011-2022 走看看