Add Processors to the Indexing Pipelines

Here is a list of processors that you can add to your pipelines to perform various tasks.

Adding a Processor to indexing.filterIndex.inbound

The following code sample shows you how to filter out items from your search indexes. In this case, the items named __Standard Values are excluded. Normally, you won’t need to adapt this code sample to make it work in your own environment.

using System;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Pipelines.IndexingFilters;
namespace Coveo.Demos.Pipelines
{
    public class ExcludeStandardValuesItemsProcessor : InboundIndexFilterProcessor
    {
        public override void Process(InboundIndexFilterArgs args)
        {
            // Here, we check whether the item being currently processed is a 'Standard Values' item. If so, we prevent it
            // from being indexed in the current search index.
            SitecoreIndexableItem item = args.IndexableToIndex as SitecoreIndexableItem;
            if (String.Equals(item.Item.Name, "__Standard Values", StringComparison.InvariantCultureIgnoreCase)) {
                args.IsExcluded = true;
            }
        }
    }
}

Using the coveoInboundFilterPipeline

The advantage of using this pipeline over the Sitecore indexing.filterIndex.inbound pipeline is that its filters can be applied to specific Coveo indexes. In other words, indexes can be included or excluded from a processor scope.

By default, a processor defined in this pipeline is applied to all Coveo indexes. To apply a processor only to specific indexes, specify those indexes name under a includedIndexNames node as follows.

<processor type="Coveo.SearchProvider.InboundFilters.ApplySitecoreInboundFilterProcessor, Coveo.SearchProviderBase">
  <includedIndexNames hint="list">
    <indexName>Coveo_web_index</indexName>
  </includedIndexNames>
</processor>

To apply a processor to all but some specific indexes, specify those index names under a excludedIndexNames node as follows.

<processor type="Coveo.SearchProvider.InboundFilters.ApplySitecoreInboundFilterProcessor, Coveo.SearchProviderBase">
  <excludedIndexNames hint="list">
    <indexName>Coveo_master_index</indexName>
  </excludedIndexNames>
</processor>

If an index is specified in both lists, the filter won’t be applied to this index.

Adding a Processor to coveoInboundFilterPipeline

The following code sample shows how you can filter out items from your search indexes. In this case, the items named __Standard Values are excluded. Normally, you won’t need to adapt this code sample to make it work in your own environment.

using Coveo.Framework.Items;
using Coveo.SearchProvider.Pipelines;
namespace Coveo.Demos.Pipelines
{
    public class ExcludeStandardValuesItemsProcessor : AbstractCoveoInboundFilterProcessor
    {
        public override void Process(CoveoInboundFilterPipelineArgs args)
        {
            // The ShouldExecute(CoveoInboundFilterPipelineArgs) tests whether the code should be executed.
            // It will return false if p_Args.IsExcluded is true or if the current index is excluded.
            if (ShouldExecute(p_Args)) {
                // Here, we check whether the item being currently processed is a 'Standard Values' item. If so, we prevent it
                // from being indexed in the current search index.
                IIndexableWrapper item = args.IndexableToIndex;
                if (String.Equals(item.Item.Name, "__Standard Values", StringComparison.InvariantCultureIgnoreCase)) {
                    args.IsExcluded = true;
                }
            }
        }
    }
}
What's Next for Me?