4

我的建议(拼写检查器)返回区分大小写的答案。(我用它来自动完成 - dog 和 Dog 返回不同的短语)\

我的建议定义如下 - 在 solrconfig -

 <searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
    <str name="name">suggest</str>
    <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
    <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
    <str name="field">suggest</str>  <!-- the indexed field to derive suggestions from -->
    <float name="threshold">0.005</float>
    <str name="buildOnCommit">true</str>
    <!--<str name="sourceLocation">american-english</str>-->
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

在模式中

<field name="suggest" type="phrase_suggest" indexed="true" stored="true" required="false" multiValued="true"/>  

<copyField source="Name" dest="suggest"/>

<fieldtype name="phrase_suggest" class="solr.TextField">
  <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.PatternReplaceFilterFactory"
            pattern="([^\p{L}\p{M}\p{N}\p{Cs}]*[\p{L}\p{M}\p{N}\p{Cs}\_]+:)|([^\p{L}\p{M}\p{N}\p{Cs}])+"
            replacement=" " replace="all"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.TrimFilterFactory"/>
  </analyzer>
</fieldtype>
4

3 回答 3

0

实际上,正确的配置参数是“queryAnalyzerFieldType”,并且必须超出列表元素,如下所示:

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">suggest</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
        <str name="field">suggest</str>  <!-- the indexed field to derive suggestions from -->
        <float name="threshold">0.005</float>
        <str name="buildOnCommit">true</str>

    </lst>
    <!-- Make it case-insensitive -->
    <str name="queryAnalyzerFieldType">text_general</str>
</searchComponent>

这适用于拼写更正和建议。

于 2015-01-14T13:15:07.487 回答
0

尝试更改添加到fieldType. 此外,放在LowerCaseFilterFactory列表的顶部。

施希尔

于 2014-02-13T05:15:00.980 回答
0

为此,您需要将字段类型添加到 solrconfig.xml 中的搜索组件声明中。在本例中为“phrase_suggestion”,但要匹配您在 schema.xml 中创建的声明了小写过滤器工厂的任何字段类型。

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">suggest</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
        <str name="field">suggest</str>  <!-- the indexed field to derive suggestions from -->
        <float name="threshold">0.005</float>
        <str name="buildOnCommit">true</str>

        <!-- THIS IS THE LINE TO ADD -->
        <str name="suggestAnalyzerFieldType">phrase_suggest</str>

    </lst>
</searchComponent>
于 2014-10-25T21:31:57.983 回答