IK如何实现同义词搜索

 

转载请声明出处,谢谢。翻译也很辛苦 

 

 

solr学习交流扣扣群340954928

 

IK如何实现同义词搜索

 

 

如何通过IK实现

 

<!--[if !supportLists]-->1、  <!--[endif]-->schema.xml中配置

 

         <fieldType name="text_ik" class="solr.TextField" >

      <analyzer type="index"  >

             <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>

                    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />

         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>    

      </analyzer>

            

      <analyzer type="query">

                   <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>

                   <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />

        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>

      </analyzer>

            

    </fieldType>

 

 

<!--[if !supportLists]-->2、  <!--[endif]-->修改solr配置文件synonyms.txt

打开synonyms.txt文件,写如下内容,另存为utf-8文件,覆盖原来的synonyms.txt文件

#some test synonym mappings unlikely to appear in real input text

aaafoo => aaabar

bbbfoo => bbbfoo bbbbar

cccfoo => cccbar cccbaz

fooaaa,baraaa,bazaaa

 

# Some synonym groups specific to this example

GB,gib,gigabyte,gigabytes

MB,mib,megabyte,megabytes

Television, Televisions, TV, TVs

#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming

#after us won't split it into two words.

 

# Synonym mappings can be used for spelling correction too

pixima => pixma

康飞,飞飞,小飞,飞机

小人 => 男人 女人 认认 人人

<!--[if !supportLists]-->3、  <!--[endif]-->创建collection,进入analysis,做测试


<!--[endif]-->

 

 

 

<!--[if !supportLists]-->4、  <!--[endif]-->后期动态维护synonyms.txt的办法是,使用zookeeper管理工具,连接到zookeeper管理中心,找到synonyms.txt文件,修改,保存。

Zookeeper管理工具下载地址:

https://github.com/woshikangfei/zookeeper

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值