solr学习笔记-增加mmesg4J中文分词

solr版本6.1、centos6.7、mmesg4j版本2.30

solr安装目录:/usr/local/solr-6.1.0

1、下载mmesg4j包:

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

2、解压/复制mmseg4j-core-1.10.0.jar、mmseg4j-solr-2.3.0.jar 到/usr/local/solr-6.1.0/dist目录下

3、编辑solrconfig.xml文件增加如下代码并保存

 

<lib dir="${solr.install.dir:../../../..}/dist/" regex="mmseg4j-core-1.10.0.jar" />
  <lib dir="${solr.install.dir:../../../..}/dist/" regex="mmseg4j-solr-2.3.0.jar" />

 

4、编辑managed-schema文件底部增加如下代码并保存

 

<fieldtype name="mmseg4jComplex" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex"  dicPath="/usr/local/solr-6.1.0/dict" />
    </analyzer>
  </fieldtype>
  <fieldtype name="mmseg4jMaxWord" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word"  dicPath="/usr/local/solr-6.1.0/dict"  />
    </analyzer>
  </fieldtype>
  <fieldtype name="mmseg4jSimple" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple"  dicPath="/usr/local/solr-6.1.0/dict" />
    </analyzer>
  </fieldtype>


5、修改相应索引字段为以上fieldtype,例如

 

 

<field name="goods_name" type="<span style="color:#ff0000;">mmseg4jMaxWord</span>" indexed="true" stored="true" required="true" multiValued="false" />


6、重启服务

 

 

/usr/local/solr-6.1.0/bin/solr restart


7、查看分词效果

 

 

 

 

 

转载于:https://www.cnblogs.com/liuensong/p/10140341.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值