Prepare the Main Sitecore Content Manager for a Scaled Environment

Once you correctly built the whole Sitecore infrastructure, you may proceed to configure Coveo for Sitecore on your main content management instance (CM1).

Step 1: Configuring the pub Database Search Index

The Sitecore Scaling Guide suggests adding a pub database, as illustrated in Sitecore Infrastructure Setup.

To index a new database, you must add a new index definition.

  1. On CM1, open the Coveo.SearchProvider.Custom.config file.

    Sitecore 7 and 8 The Coveo.SearchProvider.Custom.config file is located in the <SITECORE_INSTANCE_ROOT>\Website\App_Config\Include\Coveo\ folder.

    Sitecore 9 and 10 The Coveo.SearchProvider.Custom.config file is located in the <SITECORE_INSTANCE_ROOT>\App_Config\Include\Coveo\ folder

  2. Inside of your sitecore node, create a contentSearch/configuration/indexes element with a hint attribute like this:

     <sitecore>
       <contentSearch>
         <configuration>
           <indexes hint="list:AddIndex">
           </indexes>
         </configuration>
       </contentSearch>
     </sitecore>
    
  3. On CM1, open the Coveo.SearchProvider.config file.

    Sitecore 7 and 8 The Coveo.SearchProvider.config file is located in the <SITECORE_INSTANCE_ROOT>\Website\App_Config\Include\Coveo\ folder.

    Sitecore 9 and 10 The Coveo.SearchProvider.config file is located in the <SITECORE_INSTANCE_ROOT>\App_Config\Modules\Coveo\ folder.

  4. Find the index element that corresponds to the web database. The element should look like this:

    <index id="Coveo_web_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" patch:before = "*[2]">
    ...
    </index>
    
  5. Select and copy the whole element, from <index...> to </index>.
  6. In theCoveo.SearchProvider.Custom.config file, paste it before the </indexes> element.

    You shouldn’t modify theCoveo.SearchProvider.config file directly, as it may cause unexpected upgrade issues and loss of configuration.

  7. Apply the following changes to the element that you have just pasted.
    1. Change the value of the id attribute to Coveo_pub_index. The element should now look like this:

      <index id="Coveo_pub_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" patch:before = "*[2]">
      
    2. Increment the number in the patch:before attribute value. The element should now look like this:

      <index id="Coveo_pub_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" patch:before = "*[3]">
      
    3. Set all the index/locations/crawler/database elements value to pub. There should be at least two elements to update. The elements should now look like this:

      <database>pub</database>
      
    4. Replace the <strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync"/> node with the following nodes:

      <strategy name="OnPublishEndAsyncPub" type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch" >
        <param desc="database">pub</param>
        <!--
          Whether a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
          in ContentSearch.FullRebuildItemCountThreshold.
        -->
        <CheckForThreshold>true</CheckForThreshold>
      </strategy>
      
    5. For Sitecore 9 and 10 deployments only, you need to ensure this <strategy> element is disabled on CD servers by applying the following rule based patch.

      1. Select and copy the whole element, from <strategy...> to </strategy>.

      2. Paste the copy immediately below the original <strategy> element.

      3. Edit the second <strategy> element to obtain the following result:

        <strategy name="OnPublishEndAsyncPub" type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
          <param desc="database">pub</param>
          <!--
          Whether a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
          in ContentSearch.FullRebuildItemCountThreshold.
          -->
          <CheckForThreshold>true</CheckForThreshold>
        </strategy>
        <strategy role:require="ContentDelivery" name="OnPublishEndAsyncPub" type="Sitecore.ContentSearch.Maintenance.Strategies.ManualStrategy, Sitecore.ContentSearch">
          <param desc="database">
            <patch:delete />
          </param>
          <!--
          Whether a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
          in ContentSearch.FullRebuildItemCountThreshold.
          -->
          <CheckForThreshold>
             <patch:delete />
          </CheckForThreshold>
        </strategy>
        
  8. Save and close the files.

Step 2: Rebuilding the Search Index for the pub Database

The pub database is now properly configured and can be indexed by Coveo for Sitecore. Use the Coveo Command Center Indexing Manager to rebuild the newly created Coveo_pub_index (see Rebuild a Search Index).

Your Sitecore items are indexed with clickable URI values matching a hostName value assigned to your content management instance. However, the clickable URI is also computed whenever a Coveo-powered search interface receives search results from the index to ensure that the intended content delivery instance is hit whenever a website visitor clicks on a search result.

Step 3: Configuring the UseHostHeaderForRequestURL Setting

Under the hood, Coveo for Sitecore performs HTTP requests on its own. To ensure that these internal HTTP requests are targeting the expected endpoint, the aspnet:UseHostHeaderForRequestUrl setting must be set properly (see ASP.NET appSettings Element for details).

The aspnet:UseHostHeaderForRequestUrl setting must be set to true when the Sitecore instance is deployed behind a network load balancer (NLB). Omitting this setting may cause URL-resolving issues.

Follow these steps to configure the setting on the CM1 instance:

  1. Open your web.config file.

  2. Inside configuration / appSettings, add the following element:

     <add key="aspnet:UseHostHeaderForRequestUrl" value="true" />
    
  3. Save and close the file.

Step 4: Configuring the Farm Name on the Instance to Be Scaled

When scaling Sitecore instances, you need to set a Farm name to ensure all the Sitecore instances share the same resources. Setting a Farm name affects the names of the sources, field sets, security provider, and user identities. Instead of assigning them an individual name, you give them the same label. Follow the Assign a Farm Name to Coveo for Sitecore Resources guide to configure the CM1 instance.

When choosing a Farm name different from the CM1 host name, you must rebuild your Coveo indexes (see Coveo for Sitecore Indexing Guide). Some resources, like the sources, need to be rebuilt to apply the name change. Skipping the rebuild would cause naming inconsistencies that would prevent queries and components from reaching the right resources.

What’s Next?

Now that you installed Coveo for Sitecore on your first content management instance, you may proceed either to:

What's Next for Me?