配置文件中已配置IK分词器,
与分词器关联类型为text
除将subject配置为 <uniqueKey>subject</uniqueKey> (必须为solr.StrField类型,所以配置为string)
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
配置详情:
<fieldType name="text" class="solr.TextField">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="false"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="subject" type="string" indexed="true" stored="true"/>
<field name="content" type="text" indexed="true" stored="true"/>
<field name="searchable" type="text" indexed="true" stored="true"/>
<field name="type" type="text" indexed="true" stored="true"/>
<field name="audio" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="video" type="text" indexed="true" stored="true" multiValued="true"/>
<uniqueKey>subject</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>searchable</defaultSearchField>
用解压缩软件将IK分词器jar包,添加到solr.war中
注意 localhost:8983/solr/browser 搜索不出东西,服务器段有进一步加工,
用localhost:8983/solr/admin 直接搜索 “能够”,返回正确结果。
还要解决问题:
示例在嵌入的jetty中运行,配置直接google solr安装配置
真正环境配置中tomcat要处理中文乱码
更改server.xml 将get编码改成utf-8.
附件列表