The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class
The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class defines the search field handlers that the Commerce Engine provides out of the box.
using System.Collections.Concurrent;
namespace Sitecore.Commerce.Plugin.Search
{
/// <summary>
/// Defines the abstract index field handler.
/// </summary>
public abstract class AbstractIndexFieldHandler
{
/// <summary>
/// Composes the field value to be used in the index
/// </summary>
/// <param name="source">The source for the value</param>
/// <param name="context">The context</param>
/// <returns>The value of the field to be use in the index</returns>
public abstract object ComposeValue(object source, ConcurrentDictionary<string, object> context);
}
}The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class calls a synchronous ComposeValue method to compose the value to index.
If you have a requirement to create a custom field handler that calls a ComposeValue method asynchronously, you can refer to the sample ParentCategoryDisplayNameHander class included as an example in the Sitecore.Commerce.Engine.SDK.
-
The
sourceargument in theComposeValueprovides access to the entity that is being processed. -
The
contextdictionary provides further information about the hierarchical location of the entity, the language, the catalog that it belongs to, the current language, and more. The following table shows keys and a description of the values:Key
Value
CommerceContextThe commerce context to provide information about the current environment.
SitecoreItemSearchScopePolicyThe search scope policy provides information about the target index.
LanguageCodeThe language code.
ParentThe ID of the immediate parent entity.
MappedCatalogProvides high-level information about the catalog that this entity belongs to.
EntityHierarchyHierarchical information about the item. Provides access to the entire path to the given item.
IndexingOptionsInformation about the current indexing operation. Provides access to the target database name.
DeterministicIdThe unique ID for the entity that is also used as the Sitecore Item ID in the data provider.