首页 > 解决方案 > 自动建议器中的 Solr 服务器上下文过滤不起作用

问题描述

当我尝试将上下文过滤与自动建议器一起使用时遇到问题。我想要的是根据url 字段过滤建议

这是我的搜索组件:

      <lst name="suggester">
        <str name="name">AnalyzingInfixSuggester</str>
        <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">main_title</str>
        <str name="weightField">main_title</str>
        <str name="contextField">url</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
      </lst>

以下是我的架构中的字段:

  <field name="main_title" type="string" indexed="true" stored="true"/>
  <field name="url" type="string" indexed="true" stored="true"/>

示例:我正在搜索“aacsb”并且我有两个结果,这是正确的。一份是英文的,一份是德文的。我想过滤掉它们,只显示德语结果。

我的网址如下所示:

https://www.myWebsite.com/aacsb-dog-lion?german
https://www.myWebsite.com/aacsb-dog-lion?english

这是我的查询:

http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=-url:english

http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=-english

有了这些,我收到了两个结果。我们是否有字段名称并不重要。

当我尝试这些

http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=url:english
http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=english

我没有收到任何结果。

我多次阅读文档:LINK,但我仍然无法使其工作。

欢迎任何帮助。

谢谢!

编辑:我粘贴了错误的查询,这是正确的:

http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=url:\*english\*
http://localhost:8983/solr/myCore/suggest?&q=aacsb&suggest.dictionary=AnalyzingInfixSuggester&suggest.cfq=\*english\*

标签: solrautocompletefiltering

解决方案


推荐阅读