Hey blog viewers, Welcome to Learn Sitecore.
Sitecore SXA OOTB Search module contains many OOTB features such as search results, sort results and different filter types etc... To render the search results in a page, Search results rendering from OOTB will help. It contains the following details for the component display.
Data Source: The data source template contains a single line text field. The content given in this field will be used to render when the search results are zero for specified scope.
Rendering Parameter fields: In the rendering parameter fields we need to choose the following for the search component to work.
Search Signature: This field will help to map the search results to the correct rendering. If we add only one search results rendering to a page, this field can left blank but when more than one rendering of type search results added to the same page, this field shouldn't be blank. If the field left blank for both renderings, then which ever loads first from search results API, those results will be shown in the page for both renderings.
Scope: Here we will specify the query to filter the results. This item can be created in scopes node under site settings.
Page Size: This is used to specify the page size of the results. The same will be used in combination to the load more component that comes OOTB search feature.
Default language filtering: Select the language of search results to be shown in the page
Sort results: The configuration selected here is used to sort the results only when the sort results component is not added to the page
Auto fire search when no criteria is set: If it is unselected the search will not be triggered until the user triggers it.
We have seen about the basic details of search results component. Let's dive in to the filtering section of results where the scope is defined. Generally there are many OOTB search tokens are available to build the query but here we will be focusing on only the custom query token to apply field filter for the date.
When it comes to filtering the search results by date, there will be different scenarios that will come into picture. Let's see some of them now.
Upcoming Events: To filter only the upcoming events for the pool of events, we need to apply date range filter to the date filed defined in the events template. Solr comes with a query to filter upcoming events. That is [NOW TO *]. But to apply this in our custom query token, we need to specify that the token is used for date comparison. So Sitecore provides a token (#datecompare#) to specify this. For upcoming events the below shown query can be used.
Comments
Post a Comment