THIS IS ARCHIVED DOCUMENTATION

Creating a Custom Coveo Inbound Filter

Coveo inbound filters work exactly like Sitecore inbound filters but are adapted for a Coveo for Sitecore installation. They’re applied only to the Coveo indexes and you can even choose to which indexes you want to apply them.

Note that if excluded items were previously indexed, you must rebuild the index to delete them. Filters don’t delete items from the index, they only filter them out as they’re indexed.

Creating a Coveo Inbound Filter Processor

This section shows you how to code your own Coveo inbound filter processor, to be called for each item only indexed in the Coveo indexes.

This processor is used to exclude the items named ‘__Standard Values’.

  1. Create a new C# project that references the Sitecore.ContentSearch.dll, the Sitecore.Kernel, the Coveo.Framework.dll, and the Coveo.SearchProviderBase.dll assemblies. Those assemblies are located under: <SITECORE_INSTANCE_ROOT>\website\bin. For this tutorial, the project is named InboundFilterTest.

  2. Create a new class. For this tutorial, the class is called ApplyCoveoInboundIndexStandardValuesFilter and is located in the InboundFilterTest namespace.

Coveo inbound filters are required to:

  1. Inherit the class AbstractCoveoInboundFilterProcessor.

  2. Take arguments of type CoveoInboundFilterPipelineArgs.

  3. Invoke the ShouldExecute method to validate if the processor needs to be run.

The code below excludes the items named ‘__Standard Values’.

using Coveo.SearchProvider.Pipelines;
using Coveo.SearchProvider.InboundFilters;

namespace InboundFilterTest
{
    public class ApplyCoveoInboundIndexStandardValuesFilter : AbstractCoveoInboundFilterProcessor
    {
        public override void Process(CoveoInboundFilterPipelineArgs args)
        {
            if (args.IndexableToIndex != null && !args.IsExcluded && ShouldExecute(args)) {
                if (args.IndexableToIndex.Item.Name == "__Standard Values") {
                    args.IsExcluded = true;
                }
            }
        }
    }
}

Adding the Coveo Inbound Filter Processor to the Pipeline

  1. Open the Coveo.SearchProvider.Custom.config file.

  2. Locate the coveoInboundFilterPipeline node.

  3. Add your processor as a child node:

    <coveoInboundFilterPipeline>
      <processor type="InboundFilterTest.ApplyCoveoInboundIndexStandardValuesFilter, InboundFilterTest" />
    </coveoInboundFilterPipeline>
    
  4. Validate that the standard values items are excluded from the indexing operations.

Restricting the Processor to a Specific Index

It’s possible to define two lists in the configuration of Coveo Inbound filters:

  • Included indexes: the list of indexes the processor is applied to.

  • Excluded indexes: the list of indexes the processor isn’t applied to.

Exclusion has priority over inclusion. This means that if the same index is specified both in inclusion and exclusion, the processor isn’t applied in the index.

To define which indexes are filtered, specify the following indexes in your processor definition:

<coveoInboundFilterPipeline>
  <processor type="InboundFilterTest.ApplyCoveoInboundIndexStandardValuesFilter, InboundFilterTest">
    <!-- Includes the Coveo_web_index to the list of filtered indexes. -->
    <includedIndexNames hint="list">
      <indexName>Coveo_web_index</indexName>
    </includedIndexNames>
    <!-- Excludes the Coveo_master_index to the list of filtered indexes. -->
    <excludedIndexNames hint="list">
      <indexName>Coveo_master_index</indexName>
    </excludedIndexNames>
  </processor>
</coveoInboundFilterPipeline>