solr 中文分词 配置

效果:

     输入中国人民,包涵中国的结果能出来,包涵人民的结果也能出来。

    比较流行的中文分词是ik分词、mmseg4j分词

配置步骤(mmseg4j):

1.下载jar包 (2个 名称:mmseg4j-solr-2.3.1-SNAPSHOT.jar   mmseg4j-core-1.10.1-SNAPSHOT.jar)

 http://code.google.com/p/mmseg4j/              需要|翻|墙

http://download.csdn.net/detail/limeng650419/9531100      mmseg4j-solr-2.3.1-SNAPSHOT.jar       无需|翻|墙

http://download.csdn.net/detail/limeng650419/9531097      mmseg4j-core-1.10.1-SNAPSHOT.jar    无需|翻|墙

2.将jar包放在solr的lib目录下

   例:solr.war/WEB-INF/lib

3.在solr的conf目录下找到schema.xml 文件,配置fieldType节点

  例:<!-- mmseg4j -->

<fieldType name="mmse4j_zh" class="solr.TextField" positionIncrementGap="100">

<analyzer>

<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" />

</analyzer>

</fieldType>

 

 4.配置一个field做测试用,然后重启solr服务器

     <field name="text" type="mmse4j_zh" indexed="true" stored="true"/> 

 5.验证


 

————————完————

6.高级配置

   <!-- 中文分词mmseg4j -->

    <!--最少化分词-->

<fieldtype name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100">

   <analyzer>

<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="/data0/SolrCloud/WordsConf/mmseg4j/words" />

   </analyzer>

</fieldtype>

  <!-- 一般分词-->

<fieldtype name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100">

   <analyzer>

<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="/data0/SolrCloud/WordsConf/mmseg4j/words" />

   </analyzer>

</fieldtype>

  <!-- 最多化分词-->

<fieldtype name="text_mmseg4j_maxWord" class="solr.TextField" positionIncrementGap="100">

   <analyzer>

<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="/data0/SolrCloud/WordsConf/mmseg4j/words" />

   </analyzer>

</fieldtype>

<!--注:dicPath可以去掉-->

猜你喜欢

转载自limeng650419.iteye.com/blog/2300892