SOLR SpellCheckComponent和上下文过滤

时间:2018-06-29 11:47:34

标签: search solr search-suggestion

因此,我的网络应用使用了SpellCheckComponent。如下面的代码所示:

<searchComponent name="suggest" class="solr.SpellCheckComponent">
        <str name="queryAnalyzerFieldType">text_spell</str>
        <lst name="spellchecker">
            <str name="name">default</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">autosuggest_en</str>
            <str name="buildOnCommit">true</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
        </lst>
        <lst name="spellchecker">
            <str name="name">de</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">autosuggest_de</str>
            <str name="buildOnCommit">true</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
        </lst>
        <lst name="spellchecker">
            <str name="name">en</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">autosuggest_en</str>
            <str name="buildOnCommit">true</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
        </lst>
    </searchComponent>

    <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="spellcheck">true</str>
            <str name="spellcheck.dictionary">default</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>

所以我想知道是否有一种方法可以进行这样的配置以添加上下文过滤。我尝试做类似https://lucene.apache.org/solr/guide/6_6/suggester.html#Suggester-ContextFiltering的操作以应用于SpellCheckComponent:

<searchComponent name="suggest" class="solr.SpellCheckComponent">
        <str name="queryAnalyzerFieldType">text_spell</str>
        <lst name="spellchecker">
            <str name="name">default</str>
            <str name="classname">AnalyzingInfixLookupFactory</str>
            <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
            <str name="field">autosuggest_en</str>
            <str name="contextField">availableForWarehouses_string_mv</str>
            <str name="buildOnCommit">true</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
        </lst>
    </searchComponent>

    <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="spellcheck">true</str>
            <str name="spellcheck.dictionary">default</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>

或者像文档示例中一样:

<searchComponent name="hmmSuggest" class="solr.SuggestComponent">
        <str name="queryAnalyzerFieldType">text_spell</str>
        <lst name="suggester">
            <str name="name">default</str>
            <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
            <str name="dictionaryImpl">DocumentDictionaryFactory</str>
            <str name="field">autosuggest_en</str>
            <str name="contextField">availableForWarehouses_string_mv</str>
            <str name="suggestAnalyzerFieldType">string</str>
            <str name="buildOnStartup">true</str>
            <str name="buildOnCommit">true</str>
            <str name="buildOnOptimize">true</str>
        </lst>
    </searchComponent>

    <requestHandler name="/hmmSuggest" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="suggest">true</str>
            <str name="suggest.count">5</str>
            <str name="suggest.dictionary">default</str>
            <str name="suggest.collate">true</str>
            <str name="suggest.onlyMorePopular">true</str>
        </lst>
        <arr name="components">
            <str>hmmSuggest</str>
        </arr>
    </requestHandler>

但没有结果或异常。

所以我的问题是,是否可以使用上下文过滤来创建SpellCheckComponent,还是只能使用Askerer,如果可以,那么如何使用Askerer?

0 个答案:

没有答案