5

I'm using Sitecore 9 update 1 with SXA 1.7, I configured the auto suggester in the Solr, the suggest.count is 30 and the maximum predictive results count for the SXA search box is 30 also, but the returning results is always 5 although there is more data indexed in the Solr, I tried many things like changing numbers or removing it but still the same.

Here is my configuration for the auto suggester :

<searchComponent name="suggest" class="solr.SuggestComponent">
                    <lst name="suggester">
                      <str name="name">sxaSuggester</str>
                      <str name="lookupImpl">BlendedInfixLookupFactory</str>
                      <str name="dictionaryImpl">DocumentDictionaryFactory</str>
                      <str name="contextField">_language</str>
                      <str name="field">suggestion_s</str>
                      <str name="suggestAnalyzerFieldType">text_suggester</str>
                      <str name="payloadField">templatedisplayname_s</str>
                      <str name="buildOnStartup">true</str>
                      <str name="buildOnCommit">false</str>
                    </lst>
        </searchComponent>
        <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
                    <lst name="defaults">
                      <str name="suggest.dictionary">sxaSuggester</str>
                      <str name="suggest">true</str>
                      <str name="suggest.onlyMorePopular">true</str>
                      <str name="suggest.count">30</str>
                      <str name="suggest.collate">true</str>
                    </lst>
                    <arr name="components">
                      <str>suggest</str>
                    </arr>
        </requestHandler>

1 Answer 1

4

Unfortunately, it's hardcoded to have 5 suggestions. It definitely shouldn't be done that way and I will register a task in our backlog to change it and make it configurable.

As a workaround, you could override SolrSuggester or implement your own suggester by creating a class which implements ISuggester interface. At the end just replace SXA implementation by your one in the DI container.

You can pass a number of suggestions like that:

SuggestHandlerQueryOptions options = new SuggestHandlerQueryOptions
{
    Parameters = new SuggestParameters
    {
        Count = NUMBER_OF_SUGGESTIONS
    }
}

Investigate Sitecore.XA.Foundation.VersionSpecific.Services.SolrSuggester to have a full picture how the implementation should look like.

6
  • Thanks so much, I implemented my own suggester, but need to know where to reference it from Sitecore configuration. Commented Nov 15, 2018 at 9:52
  • We are registering it in the Sitecore.XA.Foundation.VersionSpecific.config file - section services. But what you need to do is to replace existing implementation by your own one, you can do it in the C# code (a lot of examples, just google it). Commented Nov 15, 2018 at 10:24
  • Great, I did it and it returns the count I desired, but still only 5 results are rendered, I checked the solr request and it's correct, but in the component-search-box.js, the suggestion: function (data) (which render the suggestion results)are called 5 times only. Is the count 5 is hard-coded somewhere else ? Commented Nov 15, 2018 at 11:29
  • I don't think so. Ensure that you've properly replaced SXA implementation in the DI container. Commented Nov 16, 2018 at 11:02
  • 1
    I found it out, in file typeahead.js at line 1723 : suggestions.slice(0, that.limit - rendered), it selects the first 5 elements as limit = 5, I don't know its importance so I removed the slice() function. Commented Nov 26, 2018 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.