Incremental index updates

Sitecore XC keeps indexes for Search up-to-date by periodically adding or removing items that have changed in the Commerce Engine.

The PlugIn.CatalogIndexing.PolicySet-1.0.0.json file (located in the c:\inetpub\wwwroot\<environment>\wwwroot\data\Environments folder) defines the entity types that the Commerce Engine monitors for changes, and the lists that it maintains to store information about entities that have been added, modified, or removed.

For example, the following code snippet defines a policy for monitoring sellable item entities and creating two lists to store changed items (for incremental index updates):

    "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog",
    "Name": "SellableItemsIndexMaster",
    "IncrementalListName": "SellableItemsIncrementalIndexMaster",
    "DeletedListName": "SellableItemsDeletedIndexMaster",
    "EntityTypeNames": {
      "$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
      "$values": [
        "Sitecore.Commerce.Plugin.Catalog.SellableItem, Sitecore.Commerce.Plugin.Catalog"
      ]
    },
    "IsMasterIndex": true

Property

Description

Name

A unique name for the policy.

IncrementalListName

The name of the managed list to be created for tracking new and updated entities.

DeletedListName

The name of the managed list to be created for tracking deleted entities.

EntityTypeNames

A list of .NET entity types to be tracked in the managed lists.

IsMasterIndex

Specifies whether the lists are tracking items in the Sitecore master index.

If set to true, the Commerce Engine tracks all changes.

If set to false, the Commerce Engine only tracks published changes.

Index update strategies

Index update strategies are responsible for updating specific indexes based on the information contained in the Commerce Engine’s managed lists.

The strategies run in the background and check if any entities have been created, modified, or deleted. The index and the lists that the update strategy acts on are specified in the update strategy's configuration, as is the interval at which it runs.

When an update strategy runs, it queries the Commerce Engine for the specified lists. The update strategy then updates the index accordingly by removing deleted items, and adding new or changed items, as defined in the managed lists. The update strategy also clears the Commerce Engine lists once it has processed the contents.

The sitecore.commerce.engine.connectors.index.common.config file (located in the c:\inetpub\wwwroot\<site>\App_Config_Include\Y.Commerce.Engine folder) stores the configuration that defines all update strategies. The following index update strategy classes are available by default:

  • SellableItemsIntervalAsynchronousStrategy

  • CategoriesIntervalAsynchronousStrategy

  • CatalogsIntervalAsynchronousStrategy

Each strategy is responsible for tracking a different type of Commerce entity: SellableItem, Category, and Catalog respectively.

Important

Each update strategy should be configured to monitor a different Commerce Engine list. If more than one update strategy reads from the same list, all associated indexes may become out-of-date over time.

For example, the following code snippet defines an update strategy for the Sitecore master index that monitors changes to sellable item entities in the Commerce Engine:

  <sellableItemsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
   <IncrementalIndexListName>SellableItemsIncrementalIndexMaster</IncrementalIndexListName>
   <DeletedIndexListName>SellableItemsDeletedIndexMaster</DeletedIndexListName>
   <ItemsToTake>100</ItemsToTake>
   <Environments hint="list">
     <environment>HabitatAuthoring</environment>
   </Environments>
   <param desc="interval">00:10:00</param>
   <param desc="database">master</param>
 </sellableItemsIntervalAsynchronousStrategyMaster>

Property

Description

IncrementalIndexListName

The name of the list in the Commerce Engine that tracks the items that have been created or updated.

DeletedIndexListName

The name of the list in the Commerce Engine that tracks the items that have been deleted.

ItemsToTake

The maximum number of items for the update strategy to process in each batch. You can use this property to throttle the communication between the update strategy and the Commerce Engine.

Environments

A list of Commerce Engine environments to process when the update strategy performs an incremental update.

"interval"

The frequency at which the update strategy runs.

"database"

The name of the Sitecore database that contains the items being indexed (master or web).

These update strategies are associated with Sitecore indexes through references from the index configuration file (either the Sitecore.Commerce.Engine.Connectors.Index.Solr.config file or the Sitecore.Commerce.Engine.Connectors.Index.Azure.config file).

Note

Commerce Engine Connect contains the Sitecore.Commerce.Engine.Connect.Pipelines.GetChildrenToIndex processor (in the indexing.getChildrenToIndex pipeline) that prevents the default Sitecore Item crawler from indexing catalog items, to ensure that those items are not indexed twice.