Storefront search overview

Ask about this Page
Copy for AI
View as Markdown

Learn how Product Search helps customers find, filter, and sort Products on your storefront.

Storefront search helps customers find Products in an online shop. Customers enter search terms, narrow the results with filters, and sort the results, typically on a product listing page, which is a storefront page that lists Products. Product Search provides this functionality. It searches a dedicated search index of published Products, which provides fast and relevant results. This area covers what Product Search finds, how a business switches it on, and how fast changes to the catalog appear in search results.

Administrators and storefront developers typically set up storefront search, either in the Merchant Center or with the APIs:

Key concepts

Filters and facets

Filters let customers refine the results of a search. A storefront builds dynamic filters, called facets, from the Attributes of Products. For example, customers can filter Products by size, color, or brand. A storefront can also filter results by a Category, by Price, by Store, or by Product Selection, and it can apply a filter to the results after the facets are calculated, which helps build faceted navigation.

Facets give you statistical information about your data. A facet answers questions like "how many t-shirts of size XL are there?" or "how many TVs are there that cost between US$500 and US$600?" The first question is answered by a facet that counts each distinct value of an Attribute. The second question is answered by a facet that counts the Products with a value in a specified range.

Sorting

Sorting orders the search results by criteria such as Price, name, review rating, or newest arrivals. If a storefront doesn't choose a sort order, the results are ordered by relevance, with the best match first. Sorting relies on the search index, so a change to a Product can take some time to appear in the sort order. For how long, see Index updates.

Searchable Attributes

A business decides which Attributes customers can search, filter, and facet by when it defines the Attribute on a Product Type. An Attribute is searchable only if it is marked as searchable in every Product Type that uses an Attribute with the same name. If the setting differs between Product Types, the Attribute isn't available for search, filters, or facets.

Product Search indexes both Product Attributes, which apply to the whole Product, and Variant Attributes, which apply to a single Product Variant. It indexes only the Attributes that have a value on the Product or Product Variant. If a Product Type defines an Attribute but a Product Variant has no value for it, search doesn't index that Attribute. Product Search indexes a limited number of Attributes for each Product and Product Variant. If a Product Variant has more searchable Attributes than the limit, the indexer takes them in the order in which the Product Type defines them.

Activate the Product Search API

Product Search isn't active in a Project by default. A business switches it on before first use, either in the Merchant Center or with the APIs. Once Product Search is switched on, commercetools indexes the Products. Searches work soon after, and they fail while the indexing is in progress.

Product Search switches off by itself if nobody searches for 30 consecutive days. Once it is off, the Project rejects all search requests until a business switches Product Search on again.

How the concepts relate

Product Search is for discovering Products, for example on a product listing page. The details of one Product on a product detail page come from a different source. Search returns the IDs of the matching Products. A storefront can use these IDs to load the Product data from Product Projections. A Product Projection shows the data of a Product for a specific view, such as a language or a Store. In a Project that uses the Modular catalog model, in which Product Variants are managed as separate resources, the storefront loads Product Variant data from Variant Projections. Alternatively, the GraphQL API can return the search results and their Product data in one productsSearch request.
Search uses the original Product data. Product Tailoring changes how a Product appears in a Store, but search can't sort, filter, or facet by tailored product data. A storefront can retrieve tailored data for the search results with the APIs.

Lifecycle and states

Product Search availability

The following diagram shows when Product Search is available in a Project.

Product Search is deactivated by default. When a business switches it on, commercetools indexes the Products, and searches fail until the indexing is complete. Then Product Search is activated. A business can switch it off, and commercetools switches it off after 30 days without a search. A business can switch it on again.

Index updates

Product Search reads from the search index, not directly from the Products. An event-driven indexing process keeps the index current, so a change to a Product doesn't appear in search results immediately. The product information in the search index can differ from the latest data until the indexing is complete.

The following diagram shows how a change to the catalog reaches the search index.

An incremental update takes a few minutes on average. If many Products change at once, for example in a batch, it can take longer. A full reindex takes about 15 minutes on average. It can take longer, depending on the number of Products in the catalog, the number and size of the Product Variants, the number of Standalone Prices, and the number of Product Selections and Stores in the Project.

Search doesn't update the index when a Price reaches the start or the end of its validity period. If your business relies on Prices with validity dates, contact the commercetools support team.

Common scenarios

Build a product listing page

A business with a large catalog builds a product listing page, so that customers can browse and search its Products. The page typically has the following features:

  • A search bar for full-text search.
  • A search results page that customers refine with filters, such as Category, price range, and Attributes like color, brand, style, or material.
  • Sorting, for example by price or by newest, and pagination, to split a large set of Products into manageable pages.
The business creates the filters with facets and decides which Attributes are searchable. It switches on Product Search before first use, and it loads the product details from Product Projections.