Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Out of the box the assets synchronized into Sitecore as items, goes into the default index sitecore_master_index and sitecore_web_index. In some cases it make sense to create a custom search index for all the digizuite items. For instance if the users can search for dynamic digizuite content on the website. In this guide we will show an example of an custom search index which will index all digizuite items. We will also control which fields that goes into the index. In this example we use Sitecore 10.2 and Solr v.8.8.2. This guide assume that you know how to install solr and create cores.

Sitecore configuration

Here we create the configuration for the custom index dfs_contentsearch_master_index. In this example we only create an index for the database Master and limit it to only add the items from this path /sitecore/media library/Digizuite. Remember to create the core for the new index in solr.

DFS.ContentSearch.Solr.Index.Master.config

...

Code Block
languagexml
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore search:require="solr">
    <contentSearch>
      <indexConfigurations>
        <!-- If no configuration is specified for an index, it uses the default configuration. The configurations are not merged if the index also has a
             configuration. The system uses either the default configuration or the index configuration. -->
        <DFS.ContentSearch.Solr.IndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
          <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
            <indexAllFields>true</indexAllFields>
            
			<include hint="list:AddIncludedTemplate">
              <DFSRootTemplateId>{316978B1-1C41-4F4F-82D5-82863665EDE6}</DFSRootTemplateId>
              <AssetsSiloTemplateId>{4133449F-6EC1-4D10-A930-3EC828650FA6}</AssetsSiloTemplateId>
              <AssetTemplateId>{2D63B0B3-89AA-4A87-9A32-D822C71B5BD8}</AssetTemplateId>      
              <MappedEntityTemplateId>{B8879FB6-ADE9-4971-B580-CF0073FC182A}</MappedEntityTemplateId>
              <DigizuiteEntityTemplateId>{801EC0D4-6D99-4609-B042-96388D314BFD}</DigizuiteEntityTemplateId> 
            </include>
			
            <fields hint="raw:AddComputedIndexField">
              <field fieldName="mfTitle" metafieldGuid="5eb3eefc-a043-410f-89b0-29ed3ef37078" returnType="string">DFS.Client.Services.ContentSearch.ComputedFields.DynamicMetadata, DFS.Client.Services</field>   			  
			  <field fieldName="mfPublishTo" metafieldGuid="74a5a102-a310-4bb7-9e84-0b14c36436b2" returnType="stringCollection">DFS.Client.Services.ContentSearch.ComputedFields.DynamicMetadata, DFS.Client.Services</field>	
			  <field fieldName="thumbHtmlTag" returnType="string">DFS.Client.Services.ContentSearch.ComputedFields.ThumbHtmlTag, DFS.Client.Services</field>   
			  <field fieldName="derivedFrom" returnType="string">DFS.Client.Services.ContentSearch.ComputedFields.DerivedFrom, DFS.Client.Services</field>   			  
            </fields>				
          </documentOptions> 
        </DFS.ContentSearch.Solr.IndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

We have added some AddComputedIndexField to show how to add new fields to the index, that runs som c# code to generate the values for the fields.

You can download all the code examples here:

View file
nameCustom index files.zip