1.  进入solr配置目录

cd /usr/local/solr/solrhome/collection1/conf

vi schema.xml 

增加配置节  

<fieldType name="text_syn" class="solr.TextField"> <analyzer type="query"> <tokenizer class="solr.WhitespaceTokenizerFactory"/>

<filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="index"> <tokenizer class="solr.WhitespaceTokenizerFactory"/>

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

<filter class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>

2.修改字段搜索类型  

<field name="item_DB_KeyWords" type="text_syn" indexed="true" stored="true"/>

保存  :wq

3.修改同义词配置文件   

vi synonyms.txt

纸,A4纸,打印纸,复印纸

保存:wq

4.修改扩展词

vi protwords.txt

A4纸 打印纸 复印纸

:wq

5.重启tomcat

cd /usr/local/solr/tomcat/bin

./shutdown.sh  停止

./startup.sh  启动

6.删除solr服务器数据  

<delete><query>*:*</query></delete>
<commit/>

Solr 同义词搜索

 

7.同步数据到solr服务器

8.测试搜索

Solr 同义词搜索

 

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2021-09-01
  • 2021-11-29
  • 2021-08-26
  • 2022-02-11
  • 2022-02-20
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2021-10-18
  • 2022-02-16
  • 2021-11-25
  • 2021-11-29
  • 2021-11-16
相关资源
相似解决方案