1、SmartChineseAnalyzer

   (1)将lucene-analyzers-smartcn-4.7.1.jar添加到tomcat/webapps/solr/WEB-INF/lib文件中

   (2)编辑solr主目录中conf/schema.xml文件,在<types></types>之间添加如下定义:

Solr4.7.1中配置中文分词器_solr 中文分词器

   (3)为了测试,将schema.xml中<field name="author">的type类型改为text_zh

Solr4.7.1中配置中文分词器_solr 中文分词器_02

   (4)测试,启动tomcat,浏览器访问http://localhost:8080/solr/#/collection1/analysis

Solr4.7.1中配置中文分词器_solr 中文分词器_03



2、IK Analyzer

   (1)将IKAnalyzer2012FF_u1.jar添加到tomcat/webapps/solr/WEB-INF/lib文件夹中

   (2)编辑solr主目录中conf/schema.xml文件,添加如下定义

Solr4.7.1中配置中文分词器_solr 中文分词器_04

   (3)为了配合测试,将title自动的type改为text_ik

Solr4.7.1中配置中文分词器_solr 中文分词器_05

   (4)测试,同样http://localhost:8080/solr/#/collection1/analysis

Solr4.7.1中配置中文分词器_solr 中文分词器_06


补充:

   MMSeg4j也是一个中文分词器,当前版本是1.9.1,链接:http://code.google.com/p/mmseg4j/

   我在测试过程中发现,用这个分词器在分词时会报如下错误:

java.lang.IllegalStateException: TokenStream contract violation: reset()/close() call missing, reset() called multiple times, or subclass does not call super.reset(). Please see Javadocs of TokenStream class for more information about the correct consuming workflow.

   原因是在调用incrementToken()方法之前没有调用reset()方法

   这里纠结这个问题了。。。