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、查看分词效果