Commerce Search v3 product search pipeline
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 the result without creating customer name queries. Google Retail Search does not support customer-specific product filtering. |
`1000` | `FormPreviouslyPurchasedProductQuery` | Skipped – Returns the result. Google Retail Search does not support previously purchased product boosting. |
`1700` | `FormAttributeValueAggregation` | Replaced * Queries the database for `CategoryAttributeType` entities filtered by the `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 an 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
Order | Pipe | Original Order | Changes |
|---|---|---|---|
2630 | ApplyQueryAndFilter | 3500 | Moved 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. |
2670 | ApplyPaging | 3600 | Moved 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 the 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 – Are the same as the 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 – Processes 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 – Processes search response and pagination (same as base).
- Pipe 3810: SetAdditionalFields – Sets Google-specific response fields.
- Pipes 4000-4200 – Processes explanations and suggestions (same as base).
Skipped base pipes
The following base pipes are skipped in Google Cloud Retail Search:
Order | Pipe | Changes |
|---|---|---|
700 | FormCustomerNameQuery | Overridden to skip (customer-specific products not supported). |
1000 | FormPreviouslyPurchasedProductQuery | Overridden to skip (not supported). |
2700 | PerformAggregationSearch | Merged into 2700 PerformAggregationAndSearch. |
3500 | ApplyQueryAndFilter | Moved to 2630 (base implementation at 3500 does not execute). |
3600 | ApplyPaging | Moved to 2670 (base implementation at 3600 does not execute). |
3700 | PerformSearch | Replaced by 3700 SkipPerformSearch. |