How to configure multiple contextfields in single solr suggester?

梦想与她 提交于 2020-06-11 08:38:24

问题


I am using apache solr to search records in my current application.

And I was able to filter the suggesions based on DocumentType by configuring the context field.

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>

I refer this post https://issues.apache.org/jira/browse/SOLR-7888

but still not clear how to configure multiple context fields in a single suggester .


回答1:


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"/>

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

Hope it works



来源:https://stackoverflow.com/questions/36079395/how-to-configure-multiple-contextfields-in-single-solr-suggester

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!