Skip to main content

Architecture

Tune Your Episerver Find Indexes by Only Indexing Necessary IContent

Picture of magnifying glass

Episerver Find is a great and easy way to integrate search into your Episerver powered website.  One often overlooked aspect, however, is keeping your search indexes lean.  By default, Episerver will index all instances of content across your website, whether it’s Pages, Blocks, Media, or Folders- Find doesn’t care and will index all of it.  If you follow atomic design principles or have quite a large volume of content, you may find that you hit the limits of your index prematurely.  Rather than increasing your subscription blindly, you should first look at if all of the content within your index is needed.

Viewing the Indexed Types

To view some basic diagnostics about your index, login to Episerver and navigate to the Find tool.  From the Overview tab, you should see a list of all content types that you have indexed, as well as how many items are within the index.  For instance, it may look like this:

Episerver Index Overview

 

As you can see, we have over 91,000 items in the index, with 77,000 of those items being of type EPiServer.Core.ContentAssetFolder.

Removing entries from your index

In most cases, search with Find usually revolves around searching for pages.  Rarely do we need to leverage Find to pluck out any other elements such as Blocks or Folders (although it can be useful at the API level sometimes).  Because of this, we can completely exclude these from our index.  Not only will this squeeze a little more performance out of your index (although likely negligible), but it may also drop you down a pricing tier in terms of the volume of content you require.  To remove items from your index, add this to your Find configuration:

[ModuleDependency (typeof (FindInitializationModule), typeof (IndexingModule))]
public class FindInitialization : IInitializableModule 
{
    private static bool _initialized;

    public void Initialize (InitializationEngine context) 
    {
        if (_initialized)
            return;
       
        // Remove specific items by type.  In our case, we don't want images or our base type for
        // all blocks to be indexed.  Extend with additional types as necessary
        ContentIndexer.Instance.Conventions.ForInstancesOf<ImageData>().ShouldIndex (p => false);
        ContentIndexer.Instance.Conventions.ForInstancesOf<ScoreSiteBlockData>().ShouldIndex (p => false);

        // include any additional logic related to computed fields, etc.        
        
        _initialized = true;
    }

    public void Uninitialize (InitializationEngine context) { }
}

For context, on a recent project we found that our index dropped an entire order of magnitude down in quantity.  Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dylan McCurry, Solutions Architect

I am a certified Sitecore developer, code monkey, and general nerd. I hopped into the .NET space 10 years ago to work on enterprise-class applications and never looked back. I love building things—everything from from Legos to software that solves real problems. Did I mention I love video games?

More from this Author

Follow Us