How to Disable Examine Indexing in Umbraco

Master Umbraco v11 Examine indexing: Learn how to disable external indexes for enhanced site performance, faster content publishing, and improved cold boots.

Introduction

One effective way to optimize Umbraco's performance is by disabling Examine indexing in certain situations.

In this article, we'll delve into the how and why of disabling Examine indexing in Umbraco using C#, focusing on its performance benefits and discussing when disabling external indexes is beneficial.

Understanding Examine Indexing in Umbraco

Before we dive into disabling Examine indexing, it's essential to understand its role.

Examine in Umbraco is a powerful indexing and search tool enhancing the performance and user experience of Umbraco websites.

It efficiently indexes content and provides fast search capabilities.

Performance Benefits of Disabling Examine Indexing

Turning off Examine indexing can lead to significant performance improvements, particularly in three areas:

  1. Website Cold Boot: When an Umbraco site starts, indexing processes kick in. Disabling unnecessary indexing can reduce the startup time, making the cold boot process faster.
  2. Rebuilding Indexes: Regularly rebuilding indexes can be resource-intensive. Disabling indexing, where not required, minimizes this overhead.
  3. Content Publishing: Publishing content triggers indexing. Disabling indexing can speed up the publishing process, especially on content-heavy sites.

External vs. Internal Indexes

  • External Indexes: These are typically used for site searches. Disabling external indexes can be beneficial in some cases, like sites with static content or where external services handle search functionality.
  • Internal Indexes: These are crucial for the Umbraco back office. They index users, content, etc., and are essential for efficient content management. Therefore, internal indexes should remain enabled.

Tricky Cases for Disabling External Indexes

It's not always straightforward to decide when to disable external indexes.

Consider disabling them in scenarios where:

  • The website relies heavily on static content.
  • An external service handles site search functionality.
  • The performance overhead of indexing outweighs its benefits.

Deep Dive into Disabling Examine Indexing Code in Umbraco

The provided C# code snippet is a targeted solution for disabling the external Examine index in an Umbraco application.

using Examine;

public static class UmbracoBuilderExtensions
{
	public static void DisableExamineExternalIndex(this IUmbracoBuilder builder)
	{
		var indexes = builder.Services.Where(s => s.ServiceType.Equals(typeof(IIndex)));

		builder.Services.Remove(indexes.ElementAt(1));
	}
}
public class SolutionComposer : IComposer
{
	public void Compose(IUmbracoBuilder builder)
	{
		builder.DisableExamineExternalIndex();
	}
}

Let’s dissect its components and functionality to understand how it achieves this:

Namespace Usage

The code begins with using Examine, which utilizes the Examine library.

Examine is essential for indexing and search functionality within Umbraco.

UmbracoBuilderExtensions Class

This is a static class designed to extend the functionality of IUmbracoBuilder, a key component in Umbraco's composition and configuration process.

DisableExamineExternalIndex Method

This method is an extension for IUmbracoBuilder.

It is defined to disable the Examine external index in an Umbraco application, enhancing performance under certain conditions.

Filtering Services

The line:

var indexes = builder.Services.Where(s => s.ServiceType.Equals(typeof(IIndex)));

filters the services registered in Umbraco, specifically targeting those of type IIndex, which represents Examine indexes.

Removing the External Index

The below code is critical:

builder.Services.Remove(indexes.ElementAt(1));

It removes the second item (external index) from the filtered list of indexes.

In standard Umbraco setups, the first index is usually internal (for back-office use), while the second is the external index used for site search functionalities.

SolutionComposer Class Implementation

SolutionComposer is defined to implement IComposer, an interface essential for component composition in Umbraco.

The Compose method in this class is automatically invoked during the application's startup phase.

Within Compose, the method:

builder.DisableExamineExternalIndex();

is called, which applies our previously defined logic to disable the external Examine index. 

This ensures that the disabling of the index is integrated into the application’s startup routine.

Conclusion

Disabling Examine indexing in Umbraco can lead to noticeable performance improvements in specific scenarios.

The code provided is an elegant way to disable the external Examine index in Umbraco, which can lead to performance improvements in specific scenarios.

However, it's essential to understand the structure of your Umbraco application's indexes, as this approach assumes a specific order of indexes.

Disabling the wrong index could inadvertently affect critical functionalities, like back-office searches.

Explore our blog for more insights, and feel free to reach out for any queries or discussions related to Umbraco development.

↑ Top ↑