solr6.6 配置同义词

  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、索引文件搜索

    

    

    

 

 

 

 


posted on 2017-12-19 14:21  shaomine  阅读(827)  评论(0编辑  收藏  举报