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.在搜索字段时配上这些拼音字段



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

查看所有标签

猜你喜欢:

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

Thinking Recursively

Thinking Recursively

Eric S. Roberts / Wiley / 1986-1-17 / USD 85.67

The process of solving large problems by breaking them down into smaller, more simple problems that have identical forms. Thinking Recursively: A small text to solve large problems. Concentrating on t......一起来看看 《Thinking Recursively》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

SHA 加密
SHA 加密

SHA 加密工具

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

RGB CMYK 互转工具