solrStudy-中文分词器

这里选择 IKAnalyzer2012_u5.zip 下载,下载后解压,将解压出来的 IKAnalyzer2012.jar 复制出来。在 D:\apache-solr-3.5.0\example\solr 下新建 lib 目录,将 IKAnalyzer2012.jar 放入 lib 下。打开 “D:\apache-solr-3.5.0\example\solr\conf\schema.xml” ,在 types 节点下 添加
< fieldType name = "text_zh" class = "solr.TextField" positionIncrementGap = "100" >
       < analyzer type = "index" >
         < tokenizer class = "org.wltea.analyzer.solr.IKTokenizerFactory" useSmart = "false" />
       </ analyzer >
       < analyzer type = "query" >
         < tokenizer class = "org.wltea.analyzer.solr.IKTokenizerFactory" useSmart = "false" />
       </ analyzer >
     </ fieldType >

然后在 fields 节点下引用 text_zh 这一字段类型,如下所示:

1
  < field name = "title" type = "text_zh" indexed = "true" stored = "true" />

这样标题字段就支持中文分词了。

 
<schema name="example" version="1.4">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
<fieldType name="text_zh" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" useSmart="false"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" useSmart="false"/>
</analyzer>
</fieldType>
<fieldType name="url" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1"/>
</analyzer>
</fieldType>
</types>
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="title" type="text_zh" indexed="true" stored="true"/>
<field name="description" type="text_zh" indexed="true" stored="true"/>
<field name="pubDate" type="tdate" indexed="true" stored="true"/>
<field name="link" type="url" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>title</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>
</schema>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值