Configuring site searches in SXA Storefront

Current version: 9.3

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.

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. You can configure the SXA indexes to include 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,