Friday, March 3, 2017

Content Search Web Part: Subsites not sorting correctly

If you are one of many using the Content Search web part to display all subsites of a parent site, and the sorting by Site title is not working as expected, use the following tips to get it working correctly.

1) Use one of the refinable string managed properties and map it to the 'ows_SiteName' crawled property. I used the RefinableString00 managed property.

2) Create a new Result Source on the parent site. Site Settings > Results Sources (under Search). Create a New Result Source. Give it an appropriate name, scroll down, and click the 'Launch Query Builder' button. In the Query text box, add your query as needed. I used "path:"https://company.sharepoint.com/sites/sitename" contentclass:STS_Web  UrlDepth=3" to show the first level of subsites on my parent site. Next, click the SORTING tab, and select your refinable string managed property. Select the OK button.

3) In the Content Search web part query, click the link to 'Switch to Advanced Mode'. Select your newly created Results Source in the drop-down, and clear the Query text box. Select the OK button.

4) If your subsites are still not sorting correctly in the web part, try re-indexing them. On each subsite, go to Site Settings > Search and offline availability (under Search). Click the 'Reindex Site' button.