Thursday, August 17, 2017

Sitecore: Best practices for setting up Solr core for multi-site



If you want to create separate indexes:

1. Leave sitecore_core_index, sitecore_master_index and sitecore_web_index as they are - they will be used by Sitecore to run Content Editor search and other Sitecore background searches.

2. Create Solr master and web cores for every site, e.g. site1_master_index and site1_web_index.

3. For every site, duplicate the configuration for sitecore_master_index and sitecore_web_index and set proper locations of the content roots.

E.g. create a copy of Sitecore.ContentSearch.Solr.Index.Master.config file (Site1.ContentSearch.Solr.Index.Master.config), and change its content to:


 xmlns:patch="http://www.sitecore.net/xmlconfig/">
  
    
       type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
         hint="list:AddIndex">
           id="site1_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
             desc="name">$(id)
             desc="core">$(id)
             desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
             ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
             hint="list:AddStrategy">
               ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
            
             hint="list:AddCrawler">
               type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                master
/sitecore/content/site1 type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch"> master /sitecore/media library/site1
This configuration tells Sitecore to index only /sitecore/content/site1 and /sitecore/media library/site1 locations in this index.

4. Use convention to get proper index search, e.g.:

ISearchIndex SearchIndex
{
    get
    {
        return ContentSearchManager.GetIndex(Sitecore.Context.Site.Name + "_" + Sitecore.Context.Database.Name + "_index");
    }
}

Source : https://stackoverflow.com/questions/33060048/sitecore-best-practices-for-setting-up-solr-core-for-multisite

No comments:

Post a Comment