首页 / SOLR / Solr入门之(8)中文分词器配置
Solr入门之(8)中文分词器配置
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Solr入门之(8)中文分词器配置,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2917字,纯文字阅读大概需要5分钟。
内容图文
![Solr入门之(8)中文分词器配置](/upload/InfoBanner/zyjiaocheng/1125/f32c1896cb464f7b8bb602d52462b864.jpg)
Solr中虽然提供了一个中文分词器<SPAN style=‘font-family: "Times New Roman";‘>,
但是效果很差 "Times New Roman";‘>,可以使用"Times New Roman";‘>IKAnalyzer或"Times New Roman";‘>Mmseg4j 或其他中文分词器。一、IKAnalyzer分词器配置:
1、下载<SPAN style=‘font-family: "Times New Roman";‘>IKAnalyzer(<SPAN style=‘font-family: "Times New Roman";‘>IKAnalyzer2012_u6)包<SPAN style=‘font-family: "Times New Roman";‘>,当前使用版本<SPAN style=‘font-family: "Times New Roman";‘>IKAnalyzer2012_u6.jar
2、将<SPAN style=‘font-family: "Times New Roman";‘>IKAnalyzer2012_u6包下的<SPAN style=‘font-family: "Times New Roman";‘>IKAnalyzer.cfg.xml和<SPAN style=‘font-family: "Times New Roman";‘>stopword.dic复制到<SPAN style=‘font-family: "Times New Roman";‘>solr应用<SPAN style=‘font-family: "Times New Roman";‘>/WEB-INF/classes下。
3、在<SPAN style=‘font-family: "Times New Roman";‘>${solr_home}/[core路径下<SPAN style=‘font-family: "Times New Roman";‘>]/conf/schema.xml中增加一个自定义<SPAN style=‘font-family: "Times New Roman";‘>fieldType:
<!-- 中文IK分词 --><fieldType name="text_ik_analyzer" positionIncrementGap="100" class="solr.TextField"><analyzer type="index"><tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"/><filter class="solr.StopFilterFactory" enablePositionIncrements="true" words="stopwords.txt" ignoreCase="true"/><filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" catenateAll="0" catenateNumbers="1" catenateWords="1" generateNumberParts="1" generateWordParts="1"/><filter class="solr.LowerCaseFilterFactory"/><filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/><filter class="solr.RemoveDuplicatesTokenFilterFactory"/></analyzer><analyzer type="query"><tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"/><filter class="solr.SynonymFilterFactory" ignoreCase="true" expand="true" synonyms="synonyms.txt"/><filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/><filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" catenateAll="0" catenateNumbers="0" catenateWords="0" generateNumberParts="1" generateWordParts="1"/><filter class="solr.LowerCaseFilterFactory"/><filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/><filter class="solr.RemoveDuplicatesTokenFilterFactory"/></analyzer></fieldType>
4、在<SPAN style=‘font-family: "Times New Roman";‘>schema.xml中增加一个字段:
<field name="test_ik_field" type="text_ik_analyzer" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true"/>
5、启动<SPAN style=‘font-family: "Times New Roman";‘>solr应用<SPAN style=‘font-family: "Times New Roman";‘>,即可在客户端界面查看分词效果。
二、Mmseg4j分词器:
配置方式与上面类似,暂时未定义。
原文:http://www.cnblogs.com/tq03/p/3607964.html
内容总结
以上是互联网集市为您收集整理的Solr入门之(8)中文分词器配置全部内容,希望文章能够帮你解决Solr入门之(8)中文分词器配置所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。