如何在单个Solr建议程序中配置多个contextfields? [英] How to configure multiple contextfields in single solr suggester?
问题描述
我正在使用apache solr搜索当前应用程序中的记录.
I am using apache solr to search records in my current application.
通过配置上下文字段,我能够根据DocumentType过滤建议.
And I was able to filter the suggesions based on DocumentType by configuring the context field.
现在我想添加另一个上下文字段,例如departmentType.我不确定如何为多个上下文字段配置建议程序.
Now I want to add another context field like departmentType. I am not sure how to configure the suggester for multiple context fields.
这是与单个上下文字段一起使用的建议程序,它工作正常.
This is the suggester that used with single context fields and this is working fine.
<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
但仍不清楚如何在单个建议程序中配置多个上下文字段.
but still not clear how to configure multiple context fields in a single suggester .
推荐答案
您必须在schema.xml中创建一个新字段作为context_field.
此字段应具有multivalued=true
You have to create a new field in your schema.xml as context_field.
This field should have multivalued=true
<field name="context_field" type="text_suggest" multiValued="true" indexed="true" stored="true"/>
然后,您必须在json中创建此context_field作为列表,以便在solr中建立索引.
Then you have to create this context_field as a list in json for indexing in solr.
"context_field" : ["some document type", "some department type"]
建立索引后,您可以像这样建议>
after indexing you can suggest like this-
suggest.q=b&suggest.cfq=context_documentType AND context_departmentType
希望它能起作用
这篇关于如何在单个Solr建议程序中配置多个contextfields?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!