Using the Sitecore LinkManager to Resolve URIs in a Coveo-Powered Search Page
This page explains how to configure the Sitecore LinkManager to resolve search result URIs in a Coveo-Powered Search Page.
What’s the LinkManager
The LinkManager is a module of Sitecore used to resolve URIs. For example, you may only want to display relative URIs, or add the current item language to its URI. The LinkManager is particularly useful in a multisite configuration, where an item can be accessed via different URIs that seem completely unrelated to each other.
For example, if, in your Content Tree, under the
Content node, you have the following structure:
And if your
<sites> node in your Sitecore configuration looks like this:
<site name="mysite1" hostName="www.mysite1.ca" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/mysite1" language="en" database="web" domain="extranet" enableWebEdit="true" /> <site name="mysite2" hostName="www.mysite2.ca" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/mysite2" language="en" database="web" domain="extranet" enableWebEdit="true" />
Given the above configuration, the required IIS bindings, and a properly configured
hosts file, it’s possible to access the
page1 item via the URI
www.mysite1.ca/page1 and the
page2 item via the URI
www.mysite2.ca/page2. This would also allow you to access the
page2 item with the following URI:
On a Coveo-powered search page, the site part of the clickable URI of items returned by the index sometimes needs to be updated. This modification may be required for one of the following reasons:
- In scaled environments, items are indexed on a Content Management (CM) server but are accessed by visitors through requests to a Content Delivery (CD) server. The site part of the clickable URI must therefore be updated to the intended Content Delivery site.
- The Sitecore site definitions may have been updated recently, making a site under which items were indexed invalid.
ResolveResultClickableUriProcessor processor, which you can find in your
Coveo.SearchProvider.Rest.config file, handles this operation. The
ResolveResultClickableUriProcessor processor basically sets Sitecore LinkManager options and calls its
You’re discouraged from modifying the
Coveo.SearchProvider.Rest.config file directly. You should instead implement your modifications in the
Coveo.SearchProvider.Rest.Custom.config file, to prevent unforeseen upgrade issues.
<coveoProcessParsedRestResponse> <processor type="Coveo.SearchProvider.Rest.Processors.CoveoProcessParsedRestResponse.ResolveResultClickableUriProcessor, Coveo.SearchProvider.Rest" /> </coveoProcessParsedRestResponse>
This processor uses the following fields:
uri. If you plan on removing one of these fields, insert your processor after this one.
Configuring the LinkManager
- Configure the
<sites>node of the Sitecore configuration.
Change the Sitecore site resolving settings, if necessary. Look for the nodes named
<settings>node of the Sitecore configuration. Explanations for each setting are provided in the configuration file.
For versions of Sitecore up to Sitecore 8.0 inclusively, these configurations are located in the
Web.configfile. For Sitecore 8.1 and later, these configurations are located in the
Sitecore.configfile and should only be changed using a patch file.
- Configure the format of URIs that are to be resolved in the
<linkManager>section of the
Web.configfile (for versions up to Sitecore 8.0 inclusively) or the
Sitecore.configfile (for Sitecore 8.1 and later).
See Sitecore LinkManager – Multi-site configuration to learn more on this matter.