欢迎投稿

今日深度:

solr中文分词,

solr中文分词,


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"/>


www.htsjk.Com true http://www.htsjk.com/solr/38923.html NewsArticle solr中文分词, 1、solr默认的中文分词对中文支持的不太好        2、添加比较好用的中文分词的jar,一个是 mmseg4j ,另一个是IKAnalyzer       mmseg4j-solr-2.3.0支持solr5.3,将两个jar包考...
相关文章
    暂无相关文章
评论暂时关闭