Configuring site searches in SXA Storefront

Version: 9.2

While customers who visit a storefront can browse through the product catalog, it is more likely that they will perform a search to quickly see catalog items of interest. To ensure a search on your storefront provides meaningful results, all catalog items must be indexed.

Making content easier to find

To make sure catalog content appears in search results, you must combine page and catalog content in the same index. In SXA Storefront, crawlers examine the content tree looking for page items as well as the catalogs associated with sites. Sitecore adds catalog items to the corresponding index based on the index configuration of the site.

SXA comes with a number of search-related components that rely on augmented index content. The augmented content comes from computed fields that are defined globally and, therefore, also applied to the catalog content. By having both crawlers contribute content to the same index, you can use both the SXA search components as well as the commerce search components on the storefront site.

When you create a site, you configure standard Sitecore indexes on the site to use as default search indexes to index the commerce content. Go to sitecore\Content\<tenant>\<site>\Settings\Site Groupings\<site> to view indexing settings.

Storefront component in the Site Grouping folder.

Required template inheritance for search functionality

There are two SXA templates that impact the storefront search for catalog content.

Template

Description

_Searchable

To include a product in SXA search results, you must reference this template. Without it, Sitecore does not include page nor catalog content in the SXA-specific computed field sxacontent and, as a result, SXA search components do not recognize the content.

_SearchableWithoutRelatedItems

To reduce the time needed to index catalog content, you must include this template. The SXA AggregatedContent computed field that generates the content for the indexed field SXAContent includes, by default, related items and folders. This is not needed for catalog content and it impacts performance for indexing negatively when you have large catalogs. When you include a reference to the _SearchableWithoutRelatedItems template, related items and folders are ignored.

Note

You must use both the _Searchable and _SearchableWithoutRelatedItems templates together. Just referencing the latter does not include any content in the _sxacontent field.

The following example shows the use of the _Searchable and _SearchableWithoutRelatedTopics templates.

The _Searchable and _SearchableWithoutRelatedTopics templates.

Configuring SXA Storefront to account for a custom index

A product can belong to multiple categories as well as multiple catalogs. A category can belong to multiple parent categories. The Commerce Crawler traverses the catalog content stored in the Commerce Engine instead of traversing the catalog content exposed in the Sitecore content tree by the data provider.  By taking this approach, Sitecore indexes products and categories once even if they appear in multiple locations in the tree structure. The end result is reduced indexing time. Depending on the catalog structure, the difference can be significant.

By default, SXA Storefront uses the standard indexes (sitecore_master_index and sitecore_web_index) when indexing catalog items. SXA, in contrast, uses custom indexes (sitecore_sxa_master_index and sitecore_sxa_web_index) by default. To include catalog items in the custom SXA indexes, you must add the Commerce crawler and strategies to the SXA index configuration. To avoid crawling the same content twice, you must also exclude the SXA crawlers from indexing catalog items.

Narrowing down search results

Depending on the chosen catalog structure, you can remove noise from search results so that only relevant results display. You can:

  • Clear the Include subcategory products check box to avoid having duplicate entries when products are repeated on multiple sub-levels in the category structure. Go to sitecore/Content/<tenant>/<site>/Settings/Commerce and select Catalog Configuration to change the setting in the Commerce section. This setting is used in the sample Habitat catalog, which has the same products referenced from both the first and second-level categories.

    Note

    If you have catalogs that only represent products at the lowest-level categories, you must select the check box so that the products appear when navigating first-level categories. We recommended this approach instead of configuring the same products on multiple category levels.

  • Select the Exclude Categories in Website Search Results check box to exclude the categories in which products are organized from search results. Typically, the products located within a category are more useful to include in search results than the categories themselves, which can then be omitted. Go to sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts/<site> and select Catalog Configuration to change the setting in the Commerce Control Panel section.

  • Select the Exclude Duplicate Search Results check box (sitecore/Commerce/Commerce Control Panel/Shared Settings/Indexing Settings) so that when a product exists under multiple categories, no duplicate products are displayed in search results. When you select this option, Sitecore adds only a single search entry to the search index for each product configured under the defined catalog category in the Website Search Scope setting (sitecore/Content/<tenant>/<site>/Home/Catalogs/<catalog>). The chosen instance of each product is selected by the system and is undefined. How Sitecore orders search results is not related to the location of products in the catalog hierarchy.

    Note

    To see changes on the storefront, you must rebuild the search indexes.

  • Use facets. Sitecore provides various SXA search facets as well as Commerce-specific facets that you can use when you build a search query.

Do you have some feedback for us?

If you have suggestions for improving this article,