SuggestorComponent 在 solr 中使用 contextFilter

SuggestorComponent with contextFilter in solr

我应该使用哪个查找来实现 solr Suggestor 组件中的上下文过滤?

我正在尝试在 FuzzyLookupFactory 和 AnalyzingLookupFactory 中使用 contextFiler,但它抛出了以下错误:

Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/categories: this suggester doesn't support contexts.

我的推荐人:

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">displaySuggester</str>
        <str name="lookupImpl">FuzzyLookupFactory</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">autoComplete</str>
        <str name="contextField">productCategory</str>
        <str name="suggestAnalyzerFieldType">string</str>
        <str name="buildOnStartup">false</str>
    </lst>
</searchComponent>

reference manual has the required settings:

Context filtering lets you filter suggestions by a separate context field, such as category, department or any other token. The AnalyzingInfixLookupFactory and BlendedInfixLookupFactory currently support this feature, when backed by DocumentDictionaryFactory.

请务必注意,这是 Analyzing**Infix**LookupFactory,而不是 AnalyzingLookupFactory

您已经在使用 DocumentDictionaryFactory,因此请切换到 AnalyzingInfixLookupFactoryBlendedInfixLookupFactory 以使其正常工作。