Sorting with the SharePoint Search REST API is Case Sensitive

A customer wanted to see a list of users sorted by last name, which seemed pretty simple. The data is already in the search index, and a simple REST call should be all that’s needed, I assumed.

The REST call:


The above should return all users (since I’m using the predefined source id that points to the user profile search result) whose last names begin with “d”, and the results should be sorted by lastname, ascending. However, this yielded results like:

  • Davidson
  • DeSoto
  • Dean

So, the search REST API is sorting like JavaScript, which is based on the unicode values and not a “normal” dictionary sort. The solution? I don’t know. To my knowledge, there are no options in the Search REST API to control how the sort is executed. The only solution I found was to do the sort via JavaScript.

As an aside, there is an additional problem with the REST call, above. Specifically, “lastname:d*” seems pretty simple and self-explanatory. However, SharePoint doesn’t interpret this as looking for last names that begin with “d”, it apparently interprets this looking for last names that have a word that begins with “d”. So this REST query will return the following:

  • Davidson
  • DeSoto
  • Dean
  • Smith-Davis

There may be a way to specify to only match the beginning of the field value, not the beginning of any word in the field value, but I haven’t found it yet. Again, JavaScript solved this one, though admittedly that’s a poor solution.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s