solr6.6 配置同义词

本文介绍如何在Solr中配置同义词插件,包括managed-schema配置及同义词文件synonyms-cn.txt的具体内容。通过实例展示了如何使用同义词来增强搜索体验,如拼写纠正和多义词映射。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1、配置managed-schema

<fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
      <filter class="solr.SynonymGraphFilterFactory" expand="true" ignoreCase="true" synonyms="synonyms-cn.txt"/>
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple"/>
    </analyzer>
  </fieldType>
  <field name="text" type="text_mmseg4j_simple" termVectors="true" indexed="true" stored="true"/>

  2、同义词文件synonyms-cn.txt

  

# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#-----------------------------------------------------------------------
#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 WordDelimiterGraphFilter coming
#after us won't split it into two words.

# Synonym mappings can be used for spelling correction too
pixima => pixma

ideapad,ideacenter,lenovo,联想
china,中国,中华人民共和国,华夏,中国大陆

 下面两种方式都可以

联想,ideapad,ideacenter,lenovo
联想 => ideapad,ideacenter,lenovo

 

  3、索引文件搜索

    

    

    

 

 

 

 

转载于:https://www.cnblogs.com/shaosks/p/8065431.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值