How to Enable Coveo Indexing for a Custom Sitecore database on Publish

Coveo indexing of Sitecore custom database on publish

When using Coveo for Sitecore in a multi-CD environment (e.g., with staging or secondary web databases like Web2), additional configuration is required to make Coveo treat your custom database the same way it does the default web database for indexing.

In this article, you’ll learn how to configure Coveo to index a custom Sitecore database (e.g., staging) automatically after publishing.

Step 1: Create a Custom Coveo Index for Your Database

Start by creating a new patch configuration file. Copy the settings from the default Coveo index located at: \App_Config\Modules\Coveo\Coveo.SearchProvider.config

Then, modify it to target your custom database. Here’s an example:

<configuration
  xmlns:patch="http://www.sitecore.net/xmlconfig/"
  xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore>
    <contentSearch>
      <configuration>
        <indexes hint="list:AddIndex">
          <index id="Coveo_CUSTOM_CD_NAME_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" role:require="ContentManagement">
            <param desc="p_Name">$(id)</param>
            <param desc="p_PropertyStore">
              <propertyStore ref="coveo/databasePropertyStore" param1="$(id)" />
            </param>
            <configuration ref="coveo/defaultIndexConfiguration" />
            <locations hint="list:AddCrawler">
              <crawler name="ContentCrawler" type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <database>CUSTOM_CD_NAME</database>
                <root>/sitecore/content</root>
                <stopOnError>true</stopOnError>
              </crawler>
              <crawler name="MediaLibraryCrawler" type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <database>CUSTOM_CD_NAME</database>
                <root>/sitecore/media library/Files</root>
                <stopOnError>true</stopOnError>
              </crawler>
            </locations>
            <propertyStore ref="coveo/databasePropertyStore" param1="$(id)" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/coveoOnPublishEndAsync" />
            </strategies>
            <enableItemLanguageFallback>false</enableItemLanguageFallback>
            <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

Replace CUSTOM_CD_NAME with the name of your custom content delivery database (e.g., staging, web2, etc.).

Step 2: Add a Custom Indexing Strategy for Your Database

Now, define a custom OnPublishEndAsync strategy specific to your new database.

<configuration
  xmlns:patch="http://www.sitecore.net/xmlconfig/"
  xmlns:role="http://www.sitecore.net/xmlconfig/role/"
  xmlns:localenv="http://www.sitecore.net/xmlconfig/localenv/">
  <sitecore>
    <contentSearch>
      <indexConfigurations>
        <indexUpdateStrategies>
          <coveoOnPublishEndAsyncCUSTOM_CD_NAME name="CoveoOnPublishEndAsyncCUSTOM_CD_NAME" type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
            <param desc="database">staging</param>
            <CheckForThreshold>true</CheckForThreshold>
          </coveoOnPublishEndAsyncCUSTOM_CD_NAME>
          <coveoOnPublishEndAsyncCUSTOM_CD_NAME  role:require="ContentDelivery" name="CoveoOnPublishEndAsyncCUSTOM_CD_NAME" type="Sitecore.ContentSearch.Maintenance.Strategies.ManualStrategy, Sitecore.ContentSearch">
            <param desc="database">
              <patch:delete />
            </param>
            <CheckForThreshold>
              <patch:delete />
            </CheckForThreshold>
          </coveoOnPublishEndAsyncCUSTOM_CD_NAME>
        </indexUpdateStrategies>
      </indexConfigurations>
      <configuration>
        <indexes hint="list:AddIndex">
          <index id="Coveo_CUSTOM_CD_NAME_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" role:require="ContentManagement">
            <param desc="p_Name">$(id)</param>
            <param desc="p_PropertyStore">
              <propertyStore ref="coveo/databasePropertyStore" param1="$(id)" />
            </param>
            <configuration ref="coveo/defaultIndexConfiguration" />
            <locations hint="list:AddCrawler">
              <crawler name="ContentCrawler" type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <database>CUSTOM_CD_NAME</database>
                <root>/sitecore/content</root>
                <stopOnError>true</stopOnError>
              </crawler>
              <crawler name="MediaLibraryCrawler" type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <database>CUSTOM_CD_NAME</database>
                <root>/sitecore/media library/Files</root>
                <stopOnError>true</stopOnError>
              </crawler>
            </locations>
            <propertyStore ref="coveo/databasePropertyStore" param1="$(id)" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/coveoOnPublishEndAsyncStage" />
            </strategies>
            <enableItemLanguageFallback>false</enableItemLanguageFallback>
            <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

Step 3: Rebuild the Index (If Needed)

After applying the patch to both CM and CD roles, Coveo should start updating the index for your custom database after each publish operation.

However, if you notice that indexing still isn’t working and no errors appear in the logs, check for a warning like this:

"WARN [Index=Coveo_CUSTOM_CD_NAME_index] OnPublishEndAsynchronousStrategy: The last updated timestamp of the strategy is # and exceeds the Stamp of the latest EventQueue entry #. Please rebuild the index to reinitialize the value."

If you see this message, open the Coveo Control Panel in Sitecore and manually rebuild the index for your custom database. This reinitializes the timestamp and resolves the issue.

Coveo indexing of Sitecore custom database on publish - Coveo Manual Publish

Conclusion

By configuring a custom Coveo index and a custom OnPublishEnd strategy, you enable automatic indexing of additional Sitecore databases after publishing, ideal for complex environments with multiple content delivery roles.

References

Coveo for Sitecore v5 documentation

Leave a Reply

Your email address will not be published. Required fields are marked *