Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link Sitecore Content Editor to a custom Solr search index configured for a certain Data Template?

I have created a custom Solr search index for a specific Data Template as I expect to maintain tons of items created based on that template. As you would guess I organised my items into Sitecore Item Buckets for better performance and also I could configure my Sitecore front-end to utilise that custom Solr search index. Now I would like to optimise the search across my Item Buckets in Content Editor, but it seems that Sitecore takes the master index over any custom indexes. How can I configure Sitecore to use my custom index?

like image 960
Dmitry Bastron Avatar asked Sep 12 '25 12:09

Dmitry Bastron


1 Answers

Once you have created your custom Solr index you should also have created a corresponding config file as per one of the example files provided by Sitecore. For instance, for Master DB you can use Sitecore.ContentSearch.Solr.Index.Master.config.example as a config template and simply add a patch:before="*[1]" attribute to your custom index definition as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index patch:before="*[1]" id="my_sitecore_custom_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core">$(id)</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
            </strategies>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>master</Database>
                <Root>/sitecore</Root>
              </crawler>
            </locations>
            <enableItemLanguageFallback>false</enableItemLanguageFallback>
            <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

Now Sitecore will load my_sitecore_custom_master_index index configuration as first priority and utilise it while processing any search queries for your custom items instead of the default Sitecore one.

like image 79
Kate Orlova Avatar answered Sep 15 '25 10:09

Kate Orlova