如何在单个solr建议器中配置多个上下文字段?

时间:2016-03-18 08:22:00

标签: solr spring-data-solr

我正在使用apache solr搜索当前应用程序中的记录。

我能够通过配置上下文字段来过滤基于DocumentType的建议。

现在我想添加另一个上下文字段,如departmentType。我不知道如何为多个上下文字段配置建议器。

这是与单个上下文字段一起使用的建议器,这个工作正常。

 <searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
     <str name="name">suggesterByName</str>
     <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
     <str name="dictionaryImpl">DocumentDictionaryFactory</str>
     <str name="field">fullName</str>
     <str name="contextField">documentType</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
     <str name="buildOnStartup">false</str>
   </lst>
 </searchComponent>

我推荐这篇文章 https://issues.apache.org/jira/browse/SOLR-7888

但仍然不清楚如何在单个建议器中配置多个上下文字段。

1 个答案:

答案 0 :(得分:2)

您必须在schema.xml中创建一个新字段作为context_field。 该字段应为multivalued=true

<field name="context_field" type="text_suggest" multiValued="true" indexed="true" stored="true"/>

然后你必须在json中创建这个context_field作为列表,以便在solr中进行索引。

"context_field" : ["some document type", "some department type"]
索引后你可以这样建议 -

suggest.q=b&suggest.cfq=context_documentType AND context_departmentType

希望它有效

相关问题