--- title: About the coveoItemProcessingPipeline pipeline slug: '2558' canonical_url: https://docs.coveo.com/en/2558/ collection: coveo-for-sitecore-v5 source_format: adoc --- # 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 | Item | `IIndexable` | The original item that was sent by Sitecore for indexing. | OutputItems | `List` | The items that will be indexed by Coveo for Sitecore. It contains at least the original item that was sent by Sitecore. |=== ## Configuration In the `Coveo.SearchProvider.Custom.config`, within the ``, you can patch the element with your processor as described below. ```xml ``` ## 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'll most likely need to adapt this code sample to make it work in your own environment. [source,c#] ``` 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 { 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 itemsToAdd = new List(); // 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)); } } } p_Args.OutputItems.AddRange(itemsToAdd); } } } ``` > **Note** > > To populate Coveo fields on the related media item, use a `coveoPostItemProcessingPipeline` processor instead. > See [Code sample: Adding and populating a field on a Coveo item](https://docs.coveo.com/en/2559#code-sample-adding-and-populating-a-field-on-a-coveo-item) for more details.