当前位置: 首页 > 工具软件 > Spell Check > 使用案例 >

给solr加spell check

周意智
2023-12-01

在schema.xml中添加如下内容:

<!-- A copied field for spellcheck. As it has the same stuff as the above _text_, you can use the _text_ for spellcheck in this case. But creating another dedicated copied field for spellcheck has more flexibility. -->
    <field name="spell" type="text_general" indexed="true" stored="false" multiValued="true"/>
    <copyField source="*" dest="spell"/>

同时在solrconfig.xml的<searchComponent name="spellcheck" class="solr.SpellCheckComponent"></searchComponent>中添加一下内容

<lst name="spellchecker">
    <str name="name">indexbasedchecker</str>
    <!-- The classname is optional, defaults to IndexBasedSpellChecker -->
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <!--
        Load tokens from the following field for spell checking,
        analyzer for the field's type as defined in schema.xml are used
    -->
    <str name="field">spell</str>
    <!-- Optional, by default use in-memory index (RAMDirectory) -->
    <str name="spellcheckIndexDir">./spellchecker</str>
    <!-- Set the accuracy (float) to be used for the suggestions. Default is 0.5 -->
    <str name="accuracy">0.7</str>
    <!-- Require terms to occur in 1/100th of 1% of documents in order to be included in the dictionary -->
    <float name="thresholdTokenFrequency">.0001</float>
    </lst>

 类似资料: