3

We've got a client with a Solr index, the index is updating fine but the frequency of updates seems a little high - I wondered (before digging in to this myself) if anyone knew exactly how the syncMaster strategy works?

If you have a defined root and content in the master db gets updated outside of that root - I presume that the index doesn't update? Does it add a job to check? Or does it skip the job creation?

Here's the config:

<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes hint="list:AddIndex">
      <index id="my_assets_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        <param desc="name">$(id)</param>
        <param desc="folder">$(id)</param>
        <!-- This initializes index property store. Id has to be set to the index id -->
        <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
        <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
        <strategies hint="list:AddStrategy">
          <!-- NOTE: order of these controls the execution order -->
          <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
        </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>/sitecore/media library/My Asset Folder</Root>
          </crawler>
        </locations>
      </index>
   </indexes>
</configuration>
5

When syncMaster strategy initializes, it subscribes to all the Sitecore item events (e.g. ItemCopied, ItemMoved etc) and executes its Run method every time event is fired.

public void Initialize(ISearchIndex index)
{
    CrawlingLog.Log.Info(string.Format("[Index={0}] Initializing SynchronousStrategy.", index.Name), null);

    ...

    EventHub.ItemCopied += delegate(object sender, EventArgs args)
    {
        this.Run(events.ExtractParameter<ItemUri>(args, 0), true);
    };
}

So when the item is changed (moved/deleted/added...), Run method is executed. It checks whether it should break the operation (database names different from what is defined, bulk update mode or indexing is paused) and checks if item is under the root of the index. Only if those conditions are met, IndexCustodian.UpdateItem method is executed.

public void Run(...)
{
    if (this.NeedBreakOperation(itemUri.DatabaseName))
    {
        return;
    }
    if (!this.IsItemUnderCrawlerRoot(itemUri))
    {
        return;
    }

    ...

    IndexCustodian.UpdateItem(this.index, indexableInfo);
}
1

As far as I know, the update job (crawler) is started but all items outside your root are skipped. So if an item is changed (for master, this means just saving) the job starts. But might end real fast too.

If no items with the need for add/update are detected no requests to the index are send (although that is an assumption - would need to verify that to be completely certain but seems very logical).

  • Thanks - that's what I thought too. That would certainly explain why a lot of jobs get created (if the content entry is particularly active). – Owen Niblock Oct 7 '16 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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