Conditionally replace the URI used in Coveo SearchView results
Is it possible to conditionally change the value of the href that is output in the search results based on a condition of another field in the sitecore item?
For example, we need to provide an override link in the sitecore item (this is a normal General link field). If a value is there, I want all of the hrefs to use its value in the resulting output (class='CoveoResultLink' href='myvalue'). This new URI should be used for any occurrence of the 'CoveoResultLink'.
I know that Coveo will try to build a fully qualified URI that points to the actual sitecore item. Additionally, this override link value can sometimes point to a resource within sitecore, and sometimes not.
I would create a computed field for CoveoResultLink to determine what the resulting URL is depending on if it's a Sitecore item or an external link and index it. Then, in your result template you can add a conditional based on the value of CoveoResultLink to determine whether to use clickUri or the new computed field.
The solution proposed by georgechang is the correct way at indexing time, which is the solution I would propose.
If you ever wish to override it at query time, we wrote a KB on it: https://developers.coveo.com/display/public/SupportKB/How+to+Change+the+Clickable+URI+of+an+Item+From+the+Media+Library+When+Scaling+Over+Multiple+Sitecore+CDs
The article is about scaling but the code would work in any situations.