Walkthrough: Creating a custom index
This walkthrough applies to Sitecore XC releases 9.0.2 and 9.0.3.
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.
This walkthrough describes how to:
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
Follow the instructions on the Solr website to create and initialize a new Solr core called 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. -
Add a policy block (under the "values" list) 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 contains:
-
general information about the index, such as the index name, the Solr core it's associated with, 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 an appropriate file name and.configextension (for example,my_site_master-products_index.config). -
Open the file and add your index configuration (using the example above 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.