Gravatar for daniel.reedy@tcw.com

Question by Daniel Reedy, Dec 28, 2015 7:11 PM

clickUri fails for Media Library

I upgraded from Coveo 3.0 March 2015 to December 2015. The clickUri for ordinary items works. However, the clickUri for Media Library items comes back like this:

  • /sitecore/medialibrary/Downloads/Insights/Viewpoints/082714MKTwp3434.aspx

So, it's bypassing the Media Handler, and failing to resolve, since we don't have layouts assigned to Media Lib items. The solution was simple enough (see code below), but it seems to me that this should be done by Coveo/Sitecore OTB. It was before!

public void Process(CoveoProcessParsedRestResponseArgs p_Args)
{
  string clickUri;
  string hostName = System.Web.HttpContext.Current.Request.Url.Host;

  SearchResponse response = p_Args.ResponseContent;
  foreach (SearchResult result in response.Results)
  {
    clickUri = result.ClickUri;
    if (!string.IsNullOrEmpty(clickUri))
    {
      if (clickUri.Contains(@"/sitecore/media_library/"))
      {
        clickUri = clickUri.Replace(@"/sitecore/media_library/", @"/~/media/");
      }
      result.ClickUri = clickUri;
    }
  }
}
Gravatar for slangevin@coveo.com

Comment by Simon, Jan 4, 2016 1:37 PM

This is strange indeed. In the Coveo index browser, you can look at the Details of each items. Could you please look at the Properties of both a standard item and a media library one and paste both on this thread? Make sure to remove any sensitive information in the URL.

Gravatar for daniel.reedy@tcw.com

Comment by Daniel Reedy, Jan 4, 2016 4:20 PM

Here is a normal content item:

Printable URI    localhost/sitecore_master_index - LAD1014022-CMSDev2/MetWest Total Return Bond Fund
Clickable URI    http://tcwlocal/Funds/MetWest_Funds/US_Fixed_Income/MetWest_Total_Return_Bond_Fund.aspx  
Cached version    
Title    MetWest Total Return Bond Fund
Author    n/a
Content Type    html
Language    English
Size    651 bytes
Modified Date    12/15/2015 1:15:59 PM
Indexed Date    12/24/2015 12:52:52 PM
Attachment    No
Contains attachments    No
Reference    No
Copy protected    No

And here is a Media Lib item:

Printable URI    localhost/sitecore_master_index - LAD1014022-CMSDev2/082714 MKTwp3434
Clickable URI    http://tcwlocal/sitecore/shell/~/media/Downloads/Insights/Viewpoints/082714_MKTwp3434.ashx 
Cached version    
Title    082714 MKTwp3434
Author    n/a
Content Type    pdf
Language    English
Size    268.7 KB
Modified Date    12/16/2015 10:30:58 AM
Indexed Date    12/24/2015 12:34:46 PM
Attachment    No
Contains attachments    No
Reference    No
Copy protected    No

…so, it looks right coming out of CES. But VS debugger shows that the ClickUri of the SearchResult is messed up:

VS Debug snapshot

Gravatar for slangevin@coveo.com

Comment by Simon, Jan 5, 2016 4:27 PM

Hum strange…. so there is actually no need for any processor…

The default one is

ResolveResultClickableUriProcessor

If you comment it out, which value is returned?

Gravatar for daniel.reedy@tcw.com

Comment by Daniel Reedy, Jan 11, 2016 12:52 PM

with ResolveResultClickableUriProcessor:

  result.ClickUri    "/sitecore/media_library/Downloads/Insights/Viewpoints/021314_MKTwp3270.aspx"   string

without ResolveResultClickableUriProcessor:

  result.ClickUri    "http://tcwlocal/sitecore/shell/~/media/Downloads/Insights/Viewpoints/021314_MKTwp3270.ashx"    string
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jan 11, 2016 1:03 PM

Check "clickUri" without the uppercase "C". I think this is the one modified by the processor.

Gravatar for daniel.reedy@tcw.com

Comment by Daniel Reedy, Jan 11, 2016 2:04 PM

"ClickUri" is a property of the SearchResult object in the Coveo API.

The only "clickUri" that I'm aware of is a local variable in my Process() method above… and it's initialized by SearchResult.ClickUri.

Gravatar for daniel.reedy@tcw.com

Comment by Daniel Reedy, Jan 13, 2016 2:10 PM

There is only one "ClickUri" that I know of -- it's on the SearchResult object. The "clickUri" in my original code example is a private variable, which is initialized by SearchResult.ClickUri.

0 Reply
Ask a question