By admin • June 2, 2023
For one of our clients, we had a request to create custom index for searching the news. We also need to configure SwitchOnRebuild.
New Solr Core
The first step is to create new Solr core, using Solr UI , or just copy existing core.
Navigate to <folder-where-solr-is-installed>\server\solr. You will see all the cores currently created.

I would suggest to copy scclean_web_index folder and name it sitecore_news_index. Use lower letters.
Open the folder and edit in Notepad core.properties file. Update the name to match the index folder.
name=sitecore_news_index
If you want to use SwitchOnRebuild, repeat the procedure for the secondary core - create new core and name it sitecore_news_index_sec. Change core.properties to match the core name.
name=sitecore_news_index_sec
Restart Solr, and verify that both cores are available in the Solr Admin - Core Admin.
Config file
Now is the time for the config patch. Create new file in the solution, and name it Sitecore.ContentSearch.Solr.Index.News.config. In the AddIncludedTemplate the News Template is added. You can add Events Template or any other template which you want to be stored in the index. In the crawler section the database and root folder are specified, usually root attribute contains the GUID of the News section, so everything under it will be added to the index.
After config file is deployed, rebuild the sitecore_news_index.
Here you can find example of this file.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="sitecore_news_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrSearchIndex,Sitecore.ContentSearch.SolrProvider ">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<param desc="rebuildcore">$(id)_sec</param>
<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
<configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
<include hint="list:AddIncludedTemplate">
<NewsItemTemplateId>{32C9CC0E-2FBF-4109-90C4-8849AADA1BFA}</NewsItemTemplateId>
</include>
</documentOptions>
</configuration>
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/intervalAsyncMaster" />
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
</strategies>
<commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
<policies hint="list:AddCommitPolicy">
<policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
</policies>
</commitPolicyExecutor>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>master</Database>
<Root>{F72A5801-1B41-4F51-BDB6-17BB472D18B9}</Root>
</crawler>
</locations>
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>