About the coveoItemProcessingPipeline Pipeline

This pipeline uses the CoveoItemProcessingPipelineArgs class and can be used to control which items are indexed by Coveo for Sitecore.

This pipeline is applied before items are processed by Coveo for Sitecore.

In the args, you can find the following properties:

Name Type Description



The original item that was sent by Sitecore for indexing.



The items that will be indexed by Coveo for Sitecore. It contains at least the original item that was sent by Sitecore.


In the Coveo.SearchProvider.Custom.config, within the <pipelines>, you can patch the element with your processor as described below.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <!-- Add the "coveoItemProcessingPipeline" element and your "processor" child element as illustrated
      below. Provide your namespace, class name and assembly name (minus the extension) in the "processor"
      element "type" attribute value. -->
        <processor type="[namespace].[class], [assembly]" >

Example Usage of the Pipeline

You could use this pipeline to create more items with the provided one, or to index items that would be related to the one being currently indexed.

Adding an item in the OutputItems list causes it to be processed by Coveo for Sitecore. Make sure that this item is complete before you add it.

Code Sample

The following code sample shows you how to index a Sitecore item along with its related items. You will most likely need to adapt this code sample to make it work in your own environment.

using Coveo.Framework.Processor;
using Coveo.SearchProvider.Pipelines;
using Sitecore.ContentSearch;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;

namespace Coveo.Demos.Pipelines
    public class RelatedItemPreProcessor : IProcessor<CoveoItemProcessingPipelineArgs>
        public void Process(CoveoItemProcessingPipelineArgs p_Args)
            // In this example, our goal is to retrieve the media item related to the item being currently processed, and index it along with the current item.
            // The template of the current item contains a field named 'MediaItem' of type 'Droptree' which points to a specific item located in the media library.
            List<IIndexable> itemsToAdd = new List<IIndexable>();
            // We operate on the indexables in p_Args.OutputItems in case previous processors added new items
            foreach (IIndexable indexableItem in p_Args.OutputItems) {
                SitecoreIndexableItem sitecoreIndexableItem = indexableItem as SitecoreIndexableItem;
                IIndexableBuiltinFields builtInFields = sitecoreIndexableItem;
                if (sitecoreIndexableItem != null) {
                    Item item = sitecoreIndexableItem.Item;
                    // If the item being currently processed is of the expected type (template = 'Sample Item V2'), we process it.
                    if (builtInFields.TemplateId.ToString().Equals("{41013191-AB12-4074-BFF0-3861AA2148AC}")) {
                        // Since this is a pre-processor, the Coveo Search Provider has not yet processed the current item, so we only have the raw Sitecore item (that is, SitecoreIndexableItem)
                        // in our hands.
                        // Here, we retrieve the related media library item and we append it to the list of output items.
                        // p_Args.OutputItem already contains the original item.
                        Field mediaItemField = item.Fields["MediaItem"];
                        Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase(builtInFields.Database);
                        Item relatedMediaItem = database.GetItem(mediaItemField.Value);
                        itemsToAdd.Add(new SitecoreIndexableItem(relatedMediaItem));

If you need to populate Coveo fields on the related media item, you should use a coveoPostItemProcessingPipeline processor instead. See Code sample: Adding and populating a field on a Coveo item.