给solr加spell check

来源:互联网 发布:mysql unique查询 编辑:程序博客网 时间:2024/05/19 23:16

在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>

0 0
原创粉丝点击