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可以去掉-->

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值