Hugo Santos - Head of Search Practice
14 Nov 2023
It's a common expectation for search pages to display results right after the page loads, even before the user inputs any search criteria or selects any facets. However, the default experience with a SearchStax-powered search page is to start with no results shown, which may not always be the preferred user experience.
In this post, I will demonstrate how to configure SearchStax to display search results upon page load using straightforward and efficient settings without the need for additional coding or manual query string adjustments.
Setting up your Sitecore search page to show immediate results with SearchStax can be achieved quickly and effortlessly by leveraging the tool's built-in configuration capabilities. It is crucial to understand that although our aim is to present a full array of initial results without any pre-applied filters, it's equally important that the sorting of these results follow logic and are relevant as determined by your client's preferences or standards.
To accomplish this, we will use the wildcard character (“*”) to represent a generic search query in SearchStax, effectively requesting all indexed records to be displayed.
Here is an enhanced example of what your studioConfig will look like after this addition:
const studioConfig = { "connector": { "url": "@Model.SearchStaxConfiguration.SearchEndpoint", "authentication": "@Html.Raw(authBasicToken)", "apikey": "@Model.SearchStaxConfiguration.AnalyticsApiKey", "select_auth_token": "@Model.SearchStaxConfiguration.SharedIndexReadApiKey", "suggester_auth_token": "@Model.SearchStaxConfiguration.SharedIndexReadApiKey", "search_auth_type": "@Model.SearchStaxConfiguration.SearchAuthType", "session": session, "suggester": "@Model.SearchStaxConfiguration.SuggestEndpoint", "relatedSearches": "@Model.SearchStaxConfiguration.RelatedSearchEndpoint", "searchAPIKey": "@Model.SearchStaxConfiguration.SearchApiKey", "fieldFormatters": { "date": format_date, }, "hideUniqueKey": true, "searchAdditionalArgs": "@Html.Raw(@additionalArgs)", "language": "@Model.LanguageWithoutCountry", "defaultQuery": "*" }, // Remaining configuration... };
By adding this simple line to your studioConfig, you're changing the initial behavior of your search page to be more welcoming and informative by displaying a full set of results. This adjustment creates a richer and more engaging user experience from the get-go.
Adapting your search page to exhibit a proactive display of results does more than just fill an empty space - it sets the stage for user interaction and engagement. By allowing users to see a broad spectrum of results upon page load, you cater to those who may not have a specific search in mind but are browsing through to get an idea of what is available. This practice aligns with the trend towards more dynamic and user-centric search experiences, which are increasingly expected in today’s digital landscape. Furthermore, by employing such configurations, we demonstrate how customizable and flexible the Sitecore platform is, especially when combined with the capabilities of SearchStax, to meet diverse user needs and create optimal content discovery pathways.
If you're a Sitecore developer looking to refine the search experience on your platform, consider the impactful role of configuring SearchStax to display results upon page load.
At Konabos, we specialize in fine-tuning search functionalities within the Sitecore ecosystem, including the adept use of SearchStax's powerful features. We recognize the critical importance of immediate, relevant search results and are dedicated to empowering your Sitecore site to deliver this seamless experience.
With our expertise, ensure that your users are greeted with a comprehensive display of content, fostering an efficient and engaging interaction from their first click, thereby delivering superior digital experiences that resonate with your audience.
Hugo specializes in search and automation, including testing automation. He is bright, amiable, and energetic. As a Sitecore Architect, he is passionate about creating great solutions that don't just follow best practices but further them. His passion for doing great work is equaled only by his willingness to share his expertise with the Sitecore community by blogging and advocacy, like helping to organize the Quebec Sitecore User Group while in Canada. Hugo is a four-time Sitecore Technology MVP, in recognition for all that he does for the Sitecore Community.
Share on social media