solr版本6.一、centos6.七、mmesg4j版本2.30html
solr安装目录:/usr/local/solr-6.1.0git
一、下载mmesg4j包:github
地址:https://github.com/chenlb/mmseg4j-solrcentos
二、解压/复制mmseg4j-core-1.10.0.jar、mmseg4j-solr-2.3.0.jar 到/usr/local/solr-6.1.0/dist目录下ui
三、编辑solrconfig.xml文件增长以下代码并保存spa
<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" />
四、编辑managed-schema文件底部增长以下代码并保存rest
<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>
五、修改相应索引字段为以上fieldtype,例如code
<field name="goods_name" type="<span style="color:#ff0000;">mmseg4jMaxWord</span>" indexed="true" stored="true" required="true" multiValued="false" />
六、重启服务xml
/usr/local/solr-6.1.0/bin/solr restart
七、查看分词效果htm