Recently I was working on an intranet solution based on SharePoint Online. One of the requirements was to show an overview of recently edited documents. A perfect job for the Content Search WebPart (CSWP).

After the configuration of the CSWP I found out that, by default, the results link direclty to the file, for example:

.../sites/PowerBIDemo/Shared%20Documents/Profit%20and%20Products%20Reports.xlsx

This results in a file download instead of opening it in Office Online, not very user friendly. This behavior is because of the default value “Path” of Link URL in the Property Mappings.

Content Search WebPart default Property Mappings

Content Search WebPart default Property Mappings

If you want to open a search result directly in one of the Office Web Apps you need to set the value of Link URL to ServerRedirectURL“.

Content Search WebPart changed Property Mappings

Content Search WebPart changed Property Mappings

This will result in the following url:

.../sites/PowerBIDemo/_layouts/15/WopiFrame.aspx?sourcedoc={}&
file=Products%20Sales%20Analysis.xlsx&action=default&DefaultItemOpen=1

The document will now open in one of the Office Web Apps, in this case Excel Online. The end user can now see the contents of the document in Office Online and choose one of the Edit options, in browser or using the local Office client.