Incremental index updates

Abstract

Describes the configuration that controls how the Commerce Engine periodically updates Sitecore master and web indexes with new, changed, or removed catalog entities, including catalogs, categories, and sellable items.

Sitecore XC updates search indexes by periodically adding or removing catalog entities that have changed in the Commerce Engine.

The Commerce Engine updates the Sitecore master and web indexes with new, changed, or deleted catalogs, categories, and sellable items. The incremental updates allow the search provider used by Sitecore (such as Solr, for example), to return search results that reflect the latest Commerce catalog data.

The PlugIn.CatalogIndexing.PolicySet-1.0.0.json file (located in the c:\inetpub\wwwroot\<environment>\wwwroot\data\Environments folder) defines the Catalog entity types that the Commerce Engine monitors for changes, and the lists that it maintains to store information about entities that have been added to, modified, or removed from the Commerce Engine. The IncrementalListName defines the list that is tracking changed entities. The DeleteListName defines the list that is tracking deleted entities. Catalog indexing minions watch these lists.

The following code snippet shows examples of the policies responsible to create the lists that keep track of changed and deleted items for the Sitecore master index and the Sitecore web index.

//Policy for the master index
{ 
 "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog", 
 "Name": "CatalogItemsIndexMaster",
 "IncrementalListName":"CatalogItemsIncrementalIndexMaster",
 "DeletedListName":"CatalogItemsDeletedIndexMaster",
 "EntityTypeNames": [
   "$type":"System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib"
   "$values": [     
    "Sitecore.Commerce.Plugin.Catalog.Catalog, Sitecore.Commerce.Plugin.Catalog",
    "Sitecore.Commerce.Plugin.Catalog.Category, Sitecore.Commerce.Plugin.Catalog", 
    "Sitecore.Commerce.Plugin.Catalog.SellableItem, Sitecore.Commerce.Plugin.Catalog"
  ]
},
 "IsMasterIndex": true

//Policy for the web index
{
 "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog",
 "Name": "CatalogItemsIndexWeb",
 "IncrementalListName": "CatalogItemsIncrementalIndexWeb",
 "DeletedListName": "SellableItemsDeletedIndexMaster",
 "EntityTypeNames": {
   "$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
   "$values": [
    "Sitecore.Commerce.Plugin.Catalog.Catalog, Sitecore.Commerce.Plugin.Catalog",
    "Sitecore.Commerce.Plugin.Catalog.Category,
Sitecore.Commerce.Plugin.Catalog",
    "Sitecore.Commerce.Plugin.Catalog.SellableItem,
Sitecore.Commerce.Plugin.Catalog"
  ]
},
 "IsMasterIndex": false

The following table lists and describes index properties :

Property

Description

Name

A unique name for the policy.

IncrementalListName

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

DeletedListName

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

EntityTypeNames

A list of .NET entity types to track in the managed list.

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 for catalog entities in Sitecore

The Commerce Engine defines an update strategy responsible for updating the Sitecore master and web indexes with the latest changes to Catalog entities (including catalogs, categories and sellable items). The strategy runs in the background and checks if any entities have been created, modified, or deleted.

The update strategy configuration defines the index that the strategy acts on, and the interval at which it runs.

When the index update strategy runs, it invokes the Catalog indexing minions (ItemIncrementalIndexMinion) that watch managed lists of new, changed or removed catalog entities (catalogs, categories and sellable items), and update the index accordingly.

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 update strategies for Commerce entities indexed for Sitecore content item search. The following index update strategy class is available by default and is responsible for tracking catalog, category and sellable entities:

  • CommerceEngineIntervalAsynchronousStrategy class

Important

You must configure each update strategy to monitor a different Commerce Engine list. If more than one update strategy reads from the same list, all associated indexes can become out-of-date over time.

The following code snippet shows an example of default update strategies for the Sitecore master index and for the Sitecore web index respectively:

<commerceEngineIntervalAsynchronousStrategyMaster role:require="Standalone or ContentManagement" type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CommerceEngineIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
    <IncrementalIndexListName>CatalogItemsIncrementalIndexMaster</IncrementalIndexListName>
	  <param desc="interval">00:10:00</param>
	  <param desc="database">master</param>
</commerceEngineIntervalAsynchronousStrategyMaster>
<commerceEngineIntervalAsynchronousStrategyWeb role:require="Standalone or ContentManagement" type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CommerceEngineIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
    <IncrementalIndexListName>CatalogItemsIncrementalIndexWeb</IncrementalIndexListName>
          <param desc="interval">00:10:00</param>
          <param desc="database">web</param>
</commerceEngineIntervalAsynchronousStrategyWeb>

The following table lists and describes properties of an update strategy:

Property

Description

"IncrementalIndexListName"

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

"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.