3

I'm currently trying to set up the Sitecore Publishing Service on an instance of Sitecore 10.1 (the page for all of the downloads and instructions is here)

Without the publishing service, we rely on 4 custom indexes to be updated when an item is published.

The "Publishing Module Installation and Configuration Guide" states the following about custom indexes (apologies for the formatting):

1.3.3 Configuring Cache Clearing and Indexing

The Sitecore.Publishing.Service.Delivery.config is responsible for raising events to rebuild the search indexes and clear data caches on the target instance. If additional custom indexes have been created on a Sitecore instance, each index name must be added to the publishingservice:searchindex.rebuild setting in the IndexNames section:

<event name="publishingservice:searchindex:rebuild">
    <handler
type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex">
        <IndexNames hint="list:AddIndex">
            <index>sitecore_web_index</index>
            <customIndex>MyCustomIndex</customIndex>
        </IndexNames>
    </handler>
</event>

As such, I have the following in my configuration patch file:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <events>
      <event name="publishingservice:searchindex:rebuild">
        <handler type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex">
          <IndexNames hint="list:AddIndex">
            <index>sitecore_web_index</index>
            <customIndex>customindex_1</customIndex>
            <customIndex>customindex_2</customIndex>
            <customIndex>customindex_3</customIndex>
            <customIndex>customindex_4</customIndex>
          </IndexNames>
        </handler>
      </event>
    </events>
  </sitecore>
</configuration>

The resulting output when I go to admin/ShowConfig.aspx is the following:

<event name="publishingservice:searchindex:rebuild" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
    <handler type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
        <IndexNames hint="list:AddIndex" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
           <index>sitecore_web_index</index>
           <customIndex patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">customindex_4</customIndex>
        </IndexNames>
    </handler>
</event>

So it seems that the custom index declarations are overriding each other until only the last one remains.

How should I alter the configuration files so that all of the custom indexes will be updated when an item is published through the publishing service?

2 Answers 2

1

A common way to separate multiple elements with the same name is to use a desc description attribute. This will prevent Sitecore from merging the elements and it's fairly easy to write patch expressions etc. Example:

<IndexNames ...>
  <index desc="sitecore_web_index">sitecore_web_index</index>
  <index desc="your_custom_index1">your_custom_index1</index>
  <index desc="your_custom_index2">your_custom_index2</index>
  ...
1
  • Thanks, I'll give it a try and if that works accept this answer Commented Feb 2 at 14:20
2

You need to use different tag names for each of the indexes. Otherwise Sitecore will merge them into one.

Use:

<customIndex1>customindex_1</customIndex1>
<customIndex2>customindex_2</customIndex2>
<customIndex3>customindex_3</customIndex3>
<customIndex4>customindex_4</customIndex4>
1
  • Thanks, if the other solution doesn't work I'll test this, and then if this works accept it as the answer Commented Feb 2 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.