0

I need to sort my list of sites retrieved by search rest call but when trying to perform the action the list is not sorting. if I go to the xml I can see a property Title on which I should apply the sorting.

Xml

This is my query, I have tried with sortlist=Title:ascending also but not working. Any ideas please?

http://mysharepoint:27180/sites/portal/_api/search/query?queryText='ClientSiteType%3AClientPortal*%20contentclass%3ASTS_Site'&rowlimit=500&startrow=0&enableSorting=true&orderby=Title:ascending
  • You seem to be missing quotes, try it as sortlist='Title:ascending' – Gautam Sheth Sep 13 '18 at 15:53
  • Got 500 INTERNAL error when changing with simple quotes mysharepoint:27180/sites/portal/_api/search/…* contentclass:STS_Site'&rowlimit=100&startrow=0&enableSorting=true&sortlist='Title:ascending' . In fiddler I see <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="schemas.microsoft.com/ado/2007/08/dataservices/…, Microsoft.Office.Server.Search.REST.SearchServiceException</m:code><m:message xml:lang="en-US">An unknown error occurred.</m:message></m:error> Removing sortlist='Title:ascending' I can see the results – Carlos M Sep 13 '18 at 16:36
1

It is because the "Title" is not sortable.

You need to set the "Title" managed property to be sortable.

Central Administration -> Manage service applications -> Search service application -> Search schema -> Managed Properties -> find and edit "Title" managed property -> Enable "sort" .

When we change managed properties or add new ones, the changes take effect only after the content has been re-crawled. You must perform a full crawl after making changes in managed properties.

Manage the search schema in SharePoint Server

If you are using SharePoint Online, crawling happens automatically based on the defined crawl schedule. To make sure that the changes are crawled and fully re-indexed, we must request a re-indexing of the site, or only re-index the list or library.

How to manage search schema in SharePoint Online.

  • Thanks, you are correct, I checked the managed properties and I realized there is another field mapped to ows_SiteName which is sortable and I can sort based on this field. – Carlos M Sep 14 '18 at 14:02

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.