solr中文分词

本文介绍如何通过引入mmseg4j改进Solr的中文分词能力,包括配置步骤及测试方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、solr默认的中文分词对中文支持的不太好

      

2、添加比较好用的中文分词的jar,一个是mmseg4j,另一个是IKAnalyzer

      mmseg4j-solr-2.3.0支持solr5.3,将两个jar包考入I:\SolrServer\solr5.3.1\webapps\solr\WEB-INF\lib文件夹内

     

     

3、配置I:\SolrServer\solr5.3.1\solr\mysolr\conf文件下的schema.xml文件,新增fieldType

     

    

<fieldtype name="textComplex" class="solr.TextField"
	positionIncrementGap="100">
		<analyzer>
			<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
				mode="complex" dicPath="dic" />
		</analyzer>
	</fieldtype>
	<fieldtype name="textMaxWord" class="solr.TextField"
		positionIncrementGap="100">
		<analyzer>
			<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
				mode="max-word" />
		</analyzer>
	</fieldtype>
	<fieldtype name="textSimple" class="solr.TextField"
		positionIncrementGap="100">
		<analyzer>
			<tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"
				mode="simple" dicPath="n:/custom/path/to/my_dic" />
		</analyzer>
</fieldtype>

4、重启tomcat测试分词:(选择刚刚定义的textMaxWord)

     

5、新增要用到mmseg4j分词索引的字段 content_test  分词器选择定义好的textMaxWord

      <field name="content_test" type="textMaxWord" indexed="true" stored="true" multiValued="true"/>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值