In Coveo for Sitecore you can use the coveoItemProcessingPipeline
to add other items that should also be indexed. This is similar in concept to the Sitecore indexing.getDependencies
pipeline
public class IndexWildcardItems : IProcessor<CoveoItemProcessingPipelineArgs>
{
public void Process(CoveoItemProcessingPipelineArgs p_Args)
{
var indexableItem = p_Args.Item as SitecoreIndexableItem;
if (indexableItem != null && indexableItem.Item != null && IsCustomWildcardItem(indexableItem.Item))
{
IEnumerable<Item> wildcards = GetWildcardItems(indexableItem.Item);
p_Args.OutputItems.AddRange(wildcards.Select(x => (SitecoreIndexableItem)x));
}
}
And patch the config in:
<pipelines>
<coveoItemProcessingPipeline>
<processor type="MySite.Custom.ContentSearch.Processors.IndexWildcardItems, MySite.Custom" />
</coveoItemProcessingPipeline>
</pipelines>
You will need to provide the correct logic for IsCustomWildcardItem()
to determine if the current item being indexed is a valid Wildcard item and the logic required for GetWildcardItems(indexableItem.Item)
to return the all the items for this particular wildcard.
The items are then added to the indexing queue and will be indexed as normal like any other item.
You'll also need to handle indexing the URLs for your items. The tricky part here is determining which site an item belongs to and how to determine which wildcard an item belongs to. There are so many factors that can affect this, such as your exact set up and content architecture, so is beyond the scope of this answer without a lot more information. By default, Coveo will resolve the ClickUri
field when it is returned by the REST service. This means that if you have your LinkProvider
set up to generate the correct link then the returned URL will be generated correctly.
You can read more information about the Coveo coveoProcessParsedRestResponse
pipeline and the ResolveResultClickableUriProcessor
processor which resolves the ClickUri:
<coveoProcessParsedRestResponse patch:source="Coveo.SearchProvider.Rest.config">
<!--
This processor resolves the REST results clickUri field in the context of
the current site using the Sitecore LinkManager.
-->
<processor type="Coveo.SearchProvider.Rest.Processors.CoveoProcessParsedRestResponse.ResolveResultClickableUriProcessor, Coveo.SearchProvider.Rest"/>
</coveoProcessParsedRestResponse>
Note: The above is true for Coveo version 3, the pipelines and processors involved may be slightly different for Coveo version 4 but the concepts remain the same.