I am trying to Solr auto suggest
query from multiple fields (say for example, name_tname_t
, description_tdescription_t
) in a single request handler or same suggest.dictionarysuggest.dictionary
.
I have the configs as below, when I have multiple "field""field" under the same suggester, it's not working. Also, when I try with the same name that's also not working.
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">NameSuggester</str>
<str name="lookupImpl">FSTLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">name_t</str>
<str name="suggestAnalyzerFieldType">string</str>
</lst>
<lst name="suggester">
<str name="name">DescriptionSuggester</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="lookupImpl">FSTLookupFactory</str>
<str name="field">description_t</str>
<str name="suggestAnalyzerFieldType">string</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
<str name="suggest.dictionary">DescriptionSuggester</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
C# CodeC# Code
using (var ctx = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
{
SolrSuggestQuery q = "Description";
var options = new SuggestHandlerQueryOptions
{
Parameters = new SuggestParameters
{
Count = 10,
Build = true
}
};
var result = ctx.Suggest(q, options);
var resultnew = result.Suggestions["DescriptionSuggester"].Suggestions.Select(a => a.Term);
}