This strategy relies on the fact that no variants will be indexed as documents inside Hawksearch. It is the default strategy of the conntector.
Variant properties, decorated with [IncludeInHawksearch]
attribute, will be rolled-up inside the parent product. The product document indexed will contain information coming from both the product itself and it’s variants.
To use this indexing strategy, set variantindexingstrategy to “VariantAttributesRollUp“ in Web.config, or do not include variantindexingstrategy at all.
<hawksearch ... variantindexingstrategy="VariantAttributesRollUp" </hawksearch>
Example:
[IncludeInHawksearch] public virtual string Color { get; set; }
The “Color” property will be rolled-up from the variant to the product. The “Color” field on a product in Hawksearch will contain a list of available colors, each one of them extracted from a variant.
Considerations
Variant Indexing is unavailable under this strategy.
AddHawksearchVariantIndexing
will throw aNotSupportedException
if attempted to be used inside chain initialization. Also,VariantsIndexingHandler
andVariantsIncrementalIndexingHandler
pipes will be rendered useless and throw exceptions.Price and inventory indexing options from Web.config will have no effect, because Variant Indexing is unavailable.
Indexing Setup Example: Optimizely Foundation
A full version of the HawksearchInitialization
class used to set up indexing on the Optimizely Foundation solution can be found below:
using EPiServer.Commerce.Catalog.ContentTypes; using EPiServer.Framework; using EPiServer.Framework.Initialization; using EPiServer.ServiceLocation; using Foundation.Features.CatalogContent.Bundle; using Foundation.Features.CatalogContent.Package; using Foundation.Features.CatalogContent.Product; using Foundation.Features.CatalogContent.Variation; using Foundation.Features.Hawksearch.Indexing.Pipes; using Foundation.Features.Hawksearch.Indexing.Pipes.Pages; using Foundation.Features.Locations.LocationItemPage; using Optimizely.Hawksearch.Connector.Contracts; using Optimizely.Hawksearch.Connector.Core; using Optimizely.Hawksearch.Connector.Handlers; using Optimizely.Hawksearch.Connector.Handlers.Category; using Optimizely.Hawksearch.Connector.Handlers.Page; using Optimizely.Hawksearch.Connector.Handlers.Product; using Optimizely.Hawksearch.Connector.Initialization; using StructureMap; namespace Foundation.Features.Hawksearch.Indexing { [InitializableModule] [ModuleDependency(typeof(BasicHawksearchInitialization))] public class HawksearchInitialization : IConfigurableModule { internal Injected<IContainer> Container; public void ConfigureContainer(ServiceConfigurationContext context) { var container = context.StructureMap(); container.AddHawksearchCategoryIndexing<NodeContent>(); container.AddHawksearchProductIndexing<GenericProduct, GenericVariant>() .ExtendProductIndexing<GenericProduct, EntriesImagePipe<GenericProduct>>() .ExtendProductIndexing<GenericProduct, GenericProductAttributesPipe>(); container.AddHawksearchBundleIndexing<GenericBundle, GenericVariant>(); container.AddHawksearchPackageIndexing<GenericPackage, GenericVariant>(); container.AddHawksearchPageIndexing<LocationItemPage>() .ExtendPageIndexing<LocationItemPage, FoundationPageAttributesPipe<LocationItemPage>>() .ExtendPageIndexing<LocationItemPage, LocationItemPageAttributesPipe>(); container.AddHawksearchPageIndexing<StandardPage.StandardPage>() .ExtendPageIndexing<StandardPage.StandardPage, FoundationPageAttributesPipe<StandardPage.StandardPage>>() .ExtendPageIndexing<StandardPage.StandardPage, StandardPageAttributesPipe>(); } public void Initialize(InitializationEngine context) { Container.Service.Configure(config => { config.For<IFullIndexingChain>().Add(() => FullIndexingChain(Container.Service)) .Transient(); config.For<IIncrementalIndexingChain>().Add(() => IncrementalIndexingChain(Container.Service)) .Transient(); }); } private IndexingChain FullIndexingChain(IContainer container) { return new IndexingChain(container) .AddHandler<DeletePreviousIndexHandler>() .AddHandler<CreateIndexHandler>() .AddHandler<CategoriesIndexingHandler<NodeContent>>() .AddHandler<HierarchyRebuildHandler>() .AddHandler<ProductsIndexingHandler<GenericProduct>>() .AddHandler<BundlesIndexingHandler<GenericBundle>>() .AddHandler<PackagesIndexingHandler<GenericPackage>>() .AddHandler<PagesIndexingHandler<LocationItemPage>>() .AddHandler<PagesIndexingHandler<StandardPage.StandardPage>>() .AddHandler<RebuildIndexHandler>() .AddHandler<SetCurrentIndexHandler>(); } private IndexingChain IncrementalIndexingChain(IContainer container) { return new IndexingChain(container) .AddHandler<GetCurrentIndexHandler>() .AddHandler<CategoriesIncrementalIndexingHandler<NodeContent>>() .AddHandler<CategoriesDeletionHandler>() .AddHandler<HierarchyRebuildHandler>() .AddHandler<CategoriesCascadeIndexingHandler>() .AddHandler<ProductsIncrementalIndexingHandler<GenericProduct>>() .AddHandler<BundlesIncrementalIndexingHandler<GenericBundle>>() .AddHandler<PackagesIncrementalIndexingHandler<GenericPackage>>() .AddHandler<PagesIncrementalIndexingHandler<LocationItemPage>>() .AddHandler<PagesIncrementalIndexingHandler<StandardPage.StandardPage>>() .AddHandler<EntriesDeletionHandler>() .AddHandler<PagesDeletionHandler>() .AddHandler<RebuildIndexHandler>(); } public void Uninitialize(InitializationEngine context) { } } }