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