2

We have a catalog set up for cross-site publishing and have connected it up with our user site. We've set up the managed catalog to rewrite the urls to the local site.

We use content search webparts to display the items on our catalog pages. If I use the debugger to pause the item template when it is rendering I can inspect ctx.CurrentItem and see that there is an OriginalPath property which points to the authoring side and there is a Path property which is rewritten to the local site. This is as it should be.

The problem

When I search for the same item, I see the OriginalPath, but the Path property is empty in the search results. This means that the link in the search results goes nowhere.

I found this thread which talks about adding ServerRedirectedURL to a custom item template. I'm just using the OOTB templates -- default, item, commonbody, etc. I did notice that several of the do not have the ServerRedirectedURL property in the mapping, so I added it to them. That didn't work, and I see the ServerRedirectedURL property is always null.

I also tried using the REST search api. When I query for the same items the Path is also empty.

What is it that CSWP knows that Search Results webpart and REST api don't?

How can I get the rewritten, local, friendly Path for my search results items?

  • Have you considered building a custom search result page using CSWP instead of the Search Result Web Part? – Waldek Mastykarz - MVP Apr 12 '17 at 12:23
  • I had, but I wanted also use the the things that come with Search results like the Result types, promoted results, hit/view counting, hover panel, etc. Is it possible to do that with CSWP? – Rothrock Apr 12 '17 at 14:39
  • It is, but it's not trivial. It's been a few years since I worked with it, but I recall vaguely that only CSWP was capable of showing rewritten URLs. Unfortunately I don't know the exact reason anymore and you would have to examine the ULS log for the differences of how the same items are retrieved using CSPW and SRWP to find the exact reason. – Waldek Mastykarz - MVP Apr 13 '17 at 10:56
2
+100

If you added that managed property to default display templates you need to create new manage result type from that display template.

Go to YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol and click copy on that display template, add only different name (like WebPageNEW) and save.

Go again to YOURSITE/_layouts/15/manageresulttypes.aspx?level=sitecol and you'll see alert that you need to refresh to update new maanaged properties. Click update result types and you will see that new property.

https://blogs.technet.microsoft.com/tothesharepoint/2013/09/06/how-to-display-values-from-custom-managed-properties-in-search-results-option-1/

  • Do you mean the default search item template? And which managed property? The one that I am navigating by or the ServerRedirect URL? – Rothrock Apr 13 '17 at 14:43
  • item.default or that what you using (you could change item template in result web part properties or inspect result in developer mode to see what item you are using) and add that ServerRedirectedURL managed property in mso:managed. – Marko Tica Apr 13 '17 at 14:54
  • 1
    It was actually the term that I was using in the url rewriting. I had to add it to every template, but that was much easier than any other solution I've found! Thank you so much. – Rothrock Apr 13 '17 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.