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