The index property store

Last updated Friday, February 26, 2016 in Sitecore Experience Platform for Developer, Administrator

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 in the sitecore/contentSearch part of the Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config file. The configuration delivered with Sitecore looks like this:

<databasePropertyStore
          type="Sitecore.ContentSearch.Maintenance.IndexDatabasePropertyStore, 
          Sitecore.ContentSearch">
            <Key>$(1)</Key>
            <Database>core</Database>
</databasePropertyStore>

This index property store configuration uses the Properties table in the Sitecore database as the persistent store, and it uses the core database.

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

<index id="content" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex,
           Sitecore.ContentSearch.LuceneProvider">
                  <param desc="name">$(id)</param>
                  <param desc="folder">$(id)</param>
                  <param desc="propertyStore"
                     ref="contentSearch/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/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.

A custom index property store

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

When you have implemented this interface, you need to define it in the configuration and assign it to indexes. You must define it in the <contentSearch /> part of the configuration, for example:

<contentSearch>
         <fileSystemPropertyStore type="Custom.IndexFileSystemPropertyStore, Custom">
            <Key>$(1)</Key>
            <FilePath>$(dataFolder)/indexpropertystore</FilePath>
         </fileSystemPropertyStore>
...
<index id="content" type="Sitecore.ContentSearch.LuceneProvider.
          LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
                  <param desc="name">$(id)</param>
                  <param desc="folder">$(id)</param>
                  <param desc="propertyStore" 
                            ref="contentSearch/fileSystemPropertyStore" 
                            param1="$(id)"/>

Send feedback about the documentation to docsite@sitecore.net.