Coveo for Sitecore: Customizing Index Parameters

Excluding items from Coveo indexing and search

Working with Coveo for Sitecore you’ve probably encountered the need to prevent some items from being indexed or displayed in your search results. The other day a client asked me how they could exclude specific user-related pages (e.g. login, registration, and change password pages) from showing up in search results. In their own words they needed an easy way to mark specific pages and prevent them from being indexed.

Sure, you could exclude certain templates by adding them to the excludeTemplate section in Coveo.SearchProvider.config. However, since these pages share a common template with other pages that should be indexed, adding them to excludeTemplate section isn’t an option. Another option would be to add filtering rules to prevent items from showing in your search results based on certain criteria. However, since this will be part of your advanced query which gets dispatched each time you run a search, adding too many filtering rules may impact performance.

This is where custom field comes into play. In the example below we used No Index field. This field comes with the BrainJocks SCORE accelerator out of the box, as part of Page Meta Data template. However, any Checkbox type field can be used to achieve this functionality.

No Index field offers a more granular approach

In order to use this during indexing, you will need to add a custom processor to your CoveoInboundFilterPipeline. So, the first step is to implement a class which inherits from AbstractCoveoInboundFilterProcessor:

public class NoIndexFilter : AbstractCoveoInboundFilterProcessor
        public override void Process(CoveoInboundFilterPipelineArgs args)
            if (args.IndexableToIndex != null && !args.IsExcluded && ShouldExecute(args))
                if (args.IndexableToIndex.Item.GetField("No Index") != null 
                    && args.IndexableToIndex.Item.GetFieldValue("No Index") == "1")
                    args.IsExcluded = true;

Last step, configure the Coveo Search Provider

After that, all that remains is to add this processor to coveoInboundFilterPipeline in SeachProvider.custom.config:

    <processor type="MyNamespace.Data.Processors.NoIndexFilter, MyNamespace.Data" />

Using this method can really give you more control and speed up your indexing operations. Until next time.

Happy Coveoing 🙂

Zoran Babovic

I have over 8 years of experience in Web Application development. I am skilled in many programming technologies including C#, MVC.NET, JavaScript, ASP.NET and jQuery. I joined BrainJocks in 2014 and became certified Sitecore developer as well as certified Coveo for Sitecore V4 developer. Since then I have used my expertise to deliver custom Sitecore and Coveo solutions for several enterprise clients. In my free time my hobbies are playing bass guitar and throwing darts. My focus is on creating high quality web applications.

More posts from Zoran >

3 comments on Coveo for Sitecore: Customizing Index Parameters

Jean-François L'HeureuxAugust 11, 2017 - Reply

Nice post Zoran. I would add that Sitecore doesn’t have the “No Index” field out of the box. It has to be added to a base template of all your templates to see it in the Content Editor.

Zoran BabovicAugust 11, 2017 - Reply

> Thank you for the feedback Jean-François. “No Index” field comes with SCORE out of the box, as part of Page Meta Data template. I will make some modifications to the post to clarify.

Jean-François L'HeureuxAugust 11, 2017 - Reply

> Thanks for the update. Again, really nice article.

Add a Comment

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

Or request call back