Walkthrough: Creating a custom index
You can create your own custom indexes for your search provider if the default indexes do not suit your purposes. This walkthrough describes how to create a new custom index, create a policy for incremental updates to the index, and configure the update strategy to update the index itself.
For the purposes of this walkthrough, the new custom index uses Solr as a search provider and contains Commerce catalog items from the Sitecore Master database.
Create a new Solr core
Create a new Solr core
To create a new Solr core:
-
Create and initialize a new Solr core and name it, for example,
mysite_master_products.
Create new Commerce Engine lists to track incremental changes
Create new Commerce Engine lists to track incremental changes
All indexing configuration is stored in the Plugin.CatalogIndexing.PolicySet-1.0.0.json file. You must add a new policy that instructs the Commerce Engine to create new lists for tracking incremental updates to your custom index.
For more information on incremental index updates in Sitecore XC, see the Incremental index updates topic.
You must add this configuration in all Commerce Engine environments.
To create new lists in Commerce Engine to track incremental changes:
-
Navigate to the
c:\inetpub\wwwroot\<environment>\wwwroot\data\Environmentsfolder and open thePlugin.CatalogIndexing.PolicySet-1.0.0.jsonfile. -
Under the
"$values"list, add a policy block to create managed lists for incremental updates to your custom index: -
Bootstrap the Commerce Engine to persist your changes.
-
Perform an IIS reset in the IIS Manager.
Create an index configuration file
Create an index configuration file
You must create a configuration file for the new custom index. The index configuration file must contain:
-
General information about the index, such as the index name, the Solr core it is associated with, and the property store.
-
References to the update strategies used to retrieve changed or deleted items for incremental updates to the index.
-
A definition for the crawler that populates the index and the root location in the content tree to start from.
-
Detailed definitions of each update strategy referenced by the index.
Example
To create a custom index configuration file:
-
Open a new text file in the
App_Config\Includefolder and save it with a relevant file name and.configextension (for example,my_site_master-products_index.config). -
Open the file and add your index configuration (using the previous example as a guide).
In addition to configuring index configuration properties, you must define the index crawler, and include configuration for the index update strategies.
-
Save your changes.
NoteIn this example, the custom index is configured to contain items from the Master database. For this reason, you would store the custom index configuration file in the
App_Config\Includefolder in your CM deployment.
Add a custom index to the list of indexes in the GetChildrenToIndex processor
Add a custom index to the list of indexes in the GetChildrenToIndex processor
You must add the new index to the Sitecore GetChildrenToIndex processor. Sitecore XC uses its own crawler to index Commerce items. The Sitecore.Commerce.Engine.Connect.Pipelines.GetChildrenToIndex processor stops the default Sitecore index crawlers from attempting to index Commerce items.
To add the custom index to the list of Sitecore children indexes:
-
In the
C:\inetpub\wwwroot\cqa-dem-01-dk1\App_Config\Include\Y.Commerce.Enginefolder, open theSitecore.Commerce.Engine.Connectors.Index.Common.configfile. -
Add the custom index to the list of indexes, as shown in the following example: