Skip to main content
Updated and highlighted the description
Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

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);
        }

I am trying to Solr auto suggest query from multiple fields (say for example, name_t, description_t) in single request handler or same suggest.dictionary.

I have the configs as below, when I have multiple "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# 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);
        }

I am trying to Solr auto suggest query from multiple fields (say for example, name_t, description_t) in a single request handler or same suggest.dictionary.

I have the configs as below, when I have multiple "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# 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);
        }
added 8 characters in body
Source Link
Sumit Helaiya
  • 3.2k
  • 2
  • 12
  • 23

I am trying to Solr auto suggestSolr auto suggest query from multiple fields (say for example, name_t, description_t) in singesingle request handler or same suggest.dictionary.

I have the configs as below, when iI have multiple "field" under the same suggester, itsit's not working. Also, when iI 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# 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);
        }

I am trying to Solr auto suggest query from multiple fields (say for example, name_t, description_t) in singe request handler or same suggest.dictionary.

I have the configs as below, when i have multiple "field" under same suggester, its 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# 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);
        }

I am trying to Solr auto suggest query from multiple fields (say for example, name_t, description_t) in single request handler or same suggest.dictionary.

I have the configs as below, when I have multiple "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# 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);
        }
Source Link
Jey
  • 373
  • 2
  • 16

Solr auto suggest from multiple fields

I am trying to Solr auto suggest query from multiple fields (say for example, name_t, description_t) in singe request handler or same suggest.dictionary.

I have the configs as below, when i have multiple "field" under same suggester, its 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# 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);
        }