solr搜索配置拼音检索

栏目: 数据库 · 发布时间: 8年前

内容简介:solr搜索配置拼音检索

1.准备jar包

将ik的jar包、pinyin4j-2.5.0​.jar、solr-4.9.0\contrib\analysis-extras\lucene-libs\lucene-analyzers-smartcn-4.9.0.jar拷贝到%TOMCAT_HOME%\webapps\solr\WEB-INF\lib下

2.修改schema.xml

<fieldType name="text_pinyin" class="solr.TextField" positionIncrementGap="0">    

<analyzer type="index">    

<tokenizer class="org.apache.lucene.analysis.cn.smart.SmartChineseSentenceTokenizerFactory"/>    

<filter class="org.apache.lucene.analysis.cn.smart.SmartChineseWordTokenFilterFactory"/>    

</analyzer>    

<analyzer type="query">         

<tokenizer class="org.apache.lucene.analysis.cn.smart.SmartChineseSentenceTokenizerFactory"/>    

<filter class="org.apache.lucene.analysis.cn.smart.SmartChineseWordTokenFilterFactory"/>    

</analyzer>    

</fieldType>  

<fieldType name="text_smartcn"     class="solr.TextField" positionIncrementGap="0">  

<analyzer type="index">  

<tokenizer     class="org.apache.lucene.analysis.cn.smart.SmartChineseSentenceTokenizerFactory"/>  

<filter class="org.apache.lucene.analysis.cn.smart.SmartChineseWordTokenFilterFactory"/>  

</analyzer>  

<analyzer type="query">    

<tokenizer     class="org.apache.lucene.analysis.cn.smart.SmartChineseSentenceTokenizerFactory"/>  

<filter class="org.apache.lucene.analysis.cn.smart.SmartChineseWordTokenFilterFactory"/>   

</analyzer>   

</fieldType>  

3.需要拼音分词的字段使用这些fieldType

4.在搜索字段时配上这些拼音字段



以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Bad Blood

Bad Blood

John Carreyrou / Knopf / 2018-5-21 / USD 27.95

The full inside story of the breathtaking rise and shocking collapse of Theranos, the multibillion-dollar biotech startup, by the prize-winning journalist who first broke the story and pursued it to t......一起来看看 《Bad Blood》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具