Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Commerce Search v3 product search pipeline

Details Optimizely Configured Commerce Search v3, explaining how it integrates Google Retail Search and Elasticsearch v7 for product searches, utilizing the RunProductSearch shared pipeline, and highlighting their distinct operational approaches.

Optimizely Configured Commerce Search v3 uses Google Retail Search for relevancy-based product searches and Elasticsearch v7 for non-relevancy-based searches. Both search engines execute the RunProductSearch shared search pipeline to perform product searches.

Elasticsearch v7 uses the shared pipeline as is, without overriding any of its pipes. Google Cloud Retail Search, however, overrides some pipes to support the Retail Search APIs.

The following sections outline how Google Cloud Retail Search extends the base RunProductSearch shared search pipeline with retail search-specific implementations.

Differences

  • Consolidated search – Google Cloud Retail Search combines the two separate search calls (PerformAggregationSearch at 2700 and PerformSearch at 3700) into a single API call at pipe 2700. This eliminates needing a separate main search query.
  • Reordered pipeline – Some pipes execute earlier in the pipeline (ApplyQueryAndFilter and ApplyPaging) to prepare the complete search descriptor before the single combined search call.

Overridden pipes

Order

Pipe

Changes from base

300

FormSortOrder

Enhanced

  • Adds PageToken handling with result.PageToken = parameter.ProductSearchParameter.PageToken.
  • Uses the title field instead of shortDescription for sorting.
  • Removes ProductNumberTiebreaker logic for certain sort types.

700

FormCustomerNameQuery

Skipped – Returns result without creating customer name queries. Google Retail Search does not support customer-specific product filtering.

1000

FormPreviouslyPurchasedProductQuery

Skipped – Returns result. Google Retail Search does not support previously purchased product boosting.

1700

FormAttributeValueAggregation

Replaced

  • Queries the database for CategoryAttributeType entities filtered by CategoryId parameter, instead of using the base facet logic.
  • Builds attribute type field names.
  • Respects Retail Search Dynamic Facets setting.
  • Limits to 200 attribute types ordered by SortOrder.

2200

FormDidYouMeanSuggestion

Modified – Adds additional check to skip if Auto Correct Enabled is true (autocorrect takes precedence over did-you-mean).

3100

ProcessAttributeValueAggregation

Replaced

  • Iterates custom processing through AggregationSearchResponse.Aggregations and matches them against AttributeType entities from the database.
  • Converts aggregation keys to the Google Attribute Field Name supported format for matching.
  • Builds AttributeTypeFacetDto and AttributeValueFacetDto manually instead of using base facet processor. This only includes facets with DocCount greater than 0.

Reordered pipes

OrderPipeOriginal OrderChanges
2630ApplyQueryAndFilter3500Moved earlier and simplified – Does not have FunctionScore query support, sponsored products filter exclusion, and ScoreFunctions collection handling. Only combines CombinedQuery and CombinedFilter using BooleanQuery with Operation.And.
2670ApplyPaging3600Moved earlier – Adds PageToken support with .WithPageToken(result.PageToken). Otherwise, it is identical to base implementation.

New pipes

Order

Pipe

Description

2650

ApplyQueryExpansion

Applies Google Cloud Retail Search query expansion feature by calling result.SearchDescriptor.WithQueryExpansion(result.SearchGeneralSettings.SearchQueryExpansion). The query expansion uses Google’s feature to expand long-tail search queries.

2700

PerformAggregationAndSearch

Replaces PerformAggregationSearch and PerformSearch

  • Combines both aggregation search (facets) and main product search into a single call to result.SearchClient.SearchAsync(result.IndexType, result.SearchDescriptor). If you enable faceted search and have aggregations, it applies them with .WithAggregations().
  • Sets both result.AggregationSearchResponse and result.SearchResponse from the same response.
  • Includes error handling with detailed logging.
  • Uses DependencyName("PerformAggregationSearch") to override the base pipe.

3700

SkipPerformSearch

Explicitly overrides the base PerformSearch pipe (3700) to skip it because the search is already performed at pipe 2700. Returns result immediately without executing search. Uses DependencyName("PerformSearch") to override the base pipe.

3810

SetAdditionalFields

Sets Google Cloud Retail Search specific response fields from the search response:

  • result.ProductSearchResult.AttributionToken - Token for tracking search attribution in Google Analytics.
  • result.ProductSearchResult.NextPageToken - Token for fetching the next page of results.
  • result.ProductSearchResult.RedirectUri - Redirect URI if Google Cloud Retail Search recommends redirecting to a specific page.

Execution flow for Google Cloud Retail Search

The modified pipeline flow is the following:

  • Pipes 100-2600 – Is the same as base pipeline (query building, aggregation setup, and suggestions).
  • Pipe 2630: ApplyQueryAndFilter – Combines query and filter. Moved from 3500.
  • Pipe 2650: ApplyQueryExpansion – Applies query expansion
  • Pipe 2670: ApplyPaging – Applies pagination with PageToken support. Moved from 3600.
  • Pipe 2700: PerformAggregationAndSearch – Replaces 2700 and 3700 with a single combined search call.
  • Pipes 2800-3400 – Process aggregations and sponsored search (same as base).
  • Pipe 3500: ApplyQueryAndFilter – Does not run (already executed at 2630).
  • Pipe 3600: ApplyPaging – Does not run (already executed at 2670).
  • Pipe 3700: SkipPerformSearch – Explicitly skips the base PerformSearch.
  • Pipes 3800-3900 – Process search response and pagination (same as base).
  • Pipe 3810: SetAdditionalFields – Set Google-specific response fields.
  • Pipes 4000-4200 – Process explanations and suggestions (same as base).

Skipped base pipes

The following base pipes are skipped in Google Cloud Retail Search:

OrderPipeChanges
700FormCustomerNameQueryOverridden to skip (customer-specific products not supported).
1000FormPreviouslyPurchasedProductQueryOverridden to skip (not supported).
2700PerformAggregationSearchMerged into 2700 PerformAggregationAndSearch.
3500ApplyQueryAndFilterMoved to 2630 (base implementation at 3500 does not execute).
3600ApplyPagingMoved to 2670 (base implementation at 3600 does not execute).
3700PerformSearchReplaced by 3700 SkipPerformSearch.