Sitecore Experience Manager

Walkthrough: Creating a custom Sitecore Forms index

Abstract

Create a custom index that only rebuilds the Sitecore Forms folder.

You can create your own custom indexes for your search provider if the default indexes do not suit your purposes. This can be convenient when you want to separate data to keep the index small and increase performance. This topic describes how to create a custom Sitecore Forms index that only rebuilds the Sitecore Forms folder, and then describes how to create a custom configuration file for the new index.

You can follow the instructions on the Solr website to create and initialize a new Solr core. However, you can also create a new Solr core by duplicating an existing Sitecore Solr core.

To create a new Solr core by copying:

  1. Navigate to C:\<solr>\server\solr and duplicate the <sitecore>_master_index folder.

  2. Change the name to, for example, <sitecore>_forms_index.

  3. Navigate to C:\<solr>\server\solr\<sitecore>_forms_index , open core.properties and update the core name to the name you used in the previous step.

    FORMS-index.png

You must create a configuration file for the new custom index.

To create a custom index configuration file:

  1. Navigate to C:\inetpub\wwwroot\<website>\App_Config\Include\ and create a new text file.

  2. Save the text file with a relevant file name and .config extension (for example, sitecore_forms_index.config).

  3. Ensure that the config file includes the following:

    • General information about the index (the index name, the Solr core it is associated with, and the type). The following example references Sitecore.ContentSearch.Solr.Index.Master.config:

      <index id="sitecore_forms_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">          
      <param desc="name">$(id)</param>            
      <param desc="core">sitecore_forms_index</param>
    • The crawler root. The following example is set to the Forms folder and Template folder:

      <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">                
      <Database>master</Database>                
      <Root>/sitecore/Forms</Root>              
      </crawler>              
      <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">                
      <Database>master</Database>                
      <Root>sitecore/templates/System/Forms folder</Root>              
      </crawler>
    • To rebuild the indexes the first time, you must include the AddIncludedField section, which adds the field to the index.

       <documentOptions ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/documentOptions">          
      <include hint="list:AddIncludedField">                   
      <fieldId>{558F9307-EBAF-480D-88B5-DFE9E63A66DE}
      </fieldId>                    
      </include>                
      </documentOptions>

    For example:

    <?xml version="1.0" encoding="utf-8"?><configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">  
    <sitecore role:require="Standalone or ContentManagement" search:require="solr">    
    <contentSearch>      
    <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">        
    <indexes hint="list:AddIndex">          
    <index id="sitecore_forms_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">            
    <param desc="name">$(id)</param>            
    <param desc="core">sitecore_forms_index</param>            
    <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />            
    <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">              
    <enableReadAccessIndexing>true</enableReadAccessIndexing>                
    <documentOptions ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/documentOptions">                    
    <include hint="list:AddIncludedField">                        
    <fieldId>{558F9307-EBAF-480D-88B5-DFE9E63A66DE}</fieldId>                    
    </include>                
    </documentOptions>            
    </configuration>            
    <strategies hint="list:AddStrategy">              
    <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/manual" role:require="ContentManagement and !Indexing" />              
    <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/intervalAsyncMaster" role:require="Standalone or (ContentManagement and Indexing)" />            
    </strategies>            
    <locations hint="list:AddCrawler">             
    <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">                
    <Database>master</Database>                
    <Root>/sitecore/Forms</Root>              
    </crawler>              
    <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">                
    <Database>master</Database>                
    <Root>sitecore/templates/System/Forms folder</Root>              
    </crawler>            
    </locations>            
    <enableItemLanguageFallback>false</enableItemLanguageFallback>            
    <enableFieldLanguageFallback>false</enableFieldLanguageFallback>          
    </index>        
    </indexes>      
    </configuration>    
    </contentSearch>  
    </sitecore></configuration> 
  4. Now you can select the custom index in the Indexing Manager dialog box.

    FORMS-index-indexing-manager.png