Commerce Search v3 extensions
How to add custom extensions for Optimizely Configured Commerce Search v3.
Prerequisites
Custom extensions
- To add custom extensions to RunProductSearch shared search pipelines, add extension pipes for both Elasticsearch v7 and Google Retail Search using the
DependencySystemSettingattribute. See the following example for guidance. - To upgrade from Commerce Search v2 to Commerce Search v3 with existing extensions for Elasticsearch v7, update those custom extension pipes using the
DependencySystemSettingattribute and replicate the pipes for both Elasticsearch v7 and Google Retail Search. See the following example for guidance. - When you extend a shared search pipeline for Elasticsearch v7 or Google Retail Search, review the pipe order and add new custom pipes to fit through this pipeline.
- You should update any Spire Blueprints to the latest release versions for the Product Listing page, search input, and autocomplete.
Example
namespace Extensions.Modules.Search.Shared.DocumentTypes.Product.Query.Pipelines.Pipes.FormProductFilter
{
using Insite.Core.Interfaces.Dependency;
using Insite.Search.GoogleCloudRetailSearch.DocumentTypes.Product;
[DependencySystemSetting("SearchGeneral", "SearchProviderName", "Elasticsearch v7")]
public sealed class FormIsDiscontinuedFilterElasticsearchV7
: IPipe<FormProductFilterParameter, FormProductFilterResult>
{
public int Order => 450;
public FormProductFilterResult Execute(
IUnitOfWork unitOfWork,
FormProductFilterParameter parameter,
FormProductFilterResult result
)
{
var filterProperty = nameof(ElasticSearchProduct.IsDiscontinued)
.ToCamelCase();
var isDiscontinuedFilter = parameter.SearchQueryBuilder.MakeFieldQuery(
filterProperty,
"false"
);
result.AllFilters.Add(isDiscontinuedFilter);
return result;
}
}
}
namespace Extensions.Modules.Search.Shared.DocumentTypes.Product.Query.Pipelines.Pipes.FormProductFilter
{
using Insite.Core.Interfaces.Dependency;
using Insite.Search.GoogleCloudRetailSearch.DocumentTypes.Product;
[DependencySystemSetting("SearchGeneral", "SearchProviderName", "Google Retail Search")]
public sealed class FormIsDiscontinuedFilterGoogleRetailSearch
: IPipe<FormProductFilterParameter, FormProductFilterResult>
{
public int Order => 450;
public FormProductFilterResult Execute(
IUnitOfWork unitOfWork,
FormProductFilterParameter parameter,
FormProductFilterResult result
)
{
var filterProperty = nameof(GoogleCloudRetailSearchProduct.IsDiscontinued)
.ToCamelCase();
var isDiscontinuedFilter = parameter.SearchQueryBuilder.MakeFieldQuery(
filterProperty,
"false"
);
result.AllFilters.Add(isDiscontinuedFilter);
return result;
}
}
}Updated 18 days ago
