SharePoint 2013 Search REST API – Sort by Title isn’t working

It is interesting that trivial thing like sorting by Title using SharePoint 2013 Search REST API took me a while to figure it out. Here is the search query, where I am trying to return all the sites with various site templates and sorted by Title.

https://intranet.niks.local/_api/search/query?querytext=’Affiliate:EMEA’&querytemplate='{searchterms} WebTemplate:STS WebTemplate:ProjectSite WebTemplate:Community’&TrimDuplicates=false& SelectProperties=’SiteType,Title,Description,Url’&sortlist=’Title:ascending’&RowLimit=500

If you try to execute this query against OOB SharePoint 2013 search index, you would get “500 Internal Server” or “An Unknown Error Occurred” error.

1

1-1

The issue here is in OOB Search schema, “Title” managed property is not a sortable property. 2

The fix here is 2 steps process.

  1. You would require to make sure “Title” managed property has “Sort” enabled. One would wonder this should be enabled by default in SharePoint. This issue is well documented here – http://sharepoint.stackexchange.com/questions/194877/search-api-2013-sortlist-not-working-with-title
  2. What’s worse part about here is by enabling SORT on Title managed property won’t fix sort issue. You will no longer get error but your search results are still not fully sorted. INCREMENTAL or CONTINUOUS CRAWL search schedules won’t fix.To see all the results sorted by Title, you will require to run FULL CRAWL to populate managed property data.

After following above two steps, it should return sorted results by Title using SharePoint 2013 Search REST API.

Advertisements
This entry was posted in SharePoint 2013. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s