The index property store

Abstract

The index property store persists metadata for search indexes.

The index property store persists some metadata for search indexes. For example, the last updated timestamp is in the index property store.

You configure the index property store by patching the sitecore/contentSearch part of the App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.DefaultConfigurations.config file. The configuration delivered with Sitecore looks like this:

<databasePropertyStore type="Sitecore.ContentSearch.Maintenance.IndexDatabasePropertyStore, Sitecore.ContentSearch">
  <Key>$(1)</Key>
  <Database role:require="!ContentDelivery">core</Database>
  <Database role:require="ContentDelivery">web</Database>
</databasePropertyStore>

<filesystemPropertyStore type="Sitecore.ContentSearch.Maintenance.IndexFileSystemPropertyStore, Sitecore.ContentSearch">
  <Key>$(1)</Key>
</filesystemPropertyStore>

By default, all indexes are configured to use the databasePropertyStore store. This index property store is based on the Properties table in the Sitecore database. It can use the core or the web databases depending on the role of Sitecore instance.

You assign the index property store to each index with this configuration:

<index id="content" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
    <param desc="name">$(id)</param>
    <param desc="core">$(id)</param>
    <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />           

You must set the first param1 attribute to $(id) or something similar. It must be unique across all indexes.

The index property store is a key/value-based storage. The key consists of a master key and the key of the record that has to be saved.

The master key depends on the configuration. In the example above, the Key parameter of the databasePropertyStore definition node (<Key>$(1)</Key>) will pick up the first parameter from the place where databasePropertyStore is referenced:

<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />

Because this record is defined in the <index /> element, the value of $(id) will be content:

<index id="content" ...>

This is how the databasePropertyStore guarantees that keys are unique across all indexes. It also appends the InstanceName to the master key, and this guarantees that keys are unique across all environments.

With the configuration described above, you can save a custom property to the index property store with this code:

index.PropertyStore.Set("docs-count", "123");

The value 123 is saved with a key similar to this: content_CM01_docs-count, where content is the index ID, and CM01 is the name of the Sitecore instance.

If you cannot use the implementation delivered by Sitecore, you can create a custom index property store implementation by implementing the IIndexPropertyStore interface:

  1. Create a class that implements the IIndexPropertyStore interface.

  2. Specify it in the sitecore/contentSearch/indexConfigurations section of the Sitecore configuration. For example:

    <indexConfigurations>
                    ...
                    <customPropertyStore type="[Namespace].CustomPropertyStore, [AssemblyName]">
            <Key>$(1)</Key>
                                    ...
        </customPropertyStore>
                    ...
    </indexConfigurations>
    
  3. Assign the new property store to the indexes:

    <index id="content" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        <param desc="name">$(id)</param>
        <param desc="core">$(id)</param>
        <param desc="propertyStore" ref="contentSearch/indexConfigurations/customPropertyStore" param1="$(id)" />