Wednesday, August 19, 2015

How to do case-insensitive sorting in SharePoint search

Short answer, you can’t.


If you’re working on-premises, read on for the longer answer. If you’re working in SharePoint Online, take a deep breath, sigh, and log a support ticket so we can get this into the product.

Long answer

Sorting by default in SharePoint search is case sensitive and works well if you have characters with A-Z, which will sort A-Z and then a-z, as lower case letters have a higher ascii value compared to upper case letters.

This means if you can either upper or lower case all your characters you can sort on it using a sortable or refinable managed property (does not matter if the managed property is token normalized or not)

If you also want nordic characters (eg. æøöå) or any other character outside of a-z, then you have four solutions:

  1. See the short answer
  2. Go (hope) for the upper/lower case solution and disregard your special characters
  3. Create a numeric managed property for as many characters you need to sort on, LetterOne, LetterTwo, LetterThree.. Then you create a content enrichment web service where you for each character translate a/A to 1, b/B to 2..etc.. å/Å to 29, and assign the numeric value to the corresponding managed property. ærLig would translate to 27 – 18 – 12, and you could use the following sort list formula: LetterOne:ascending,LetterTwo:ascending,LetterThree:ascending
  4. If you can get the full result set in your query, implement the sorting in your control display template.

I would recommend the above solutions in the following order: 1,4,2,3

Simple stuff is often hard!

1 comment:

  1. This comment has been removed by a blog administrator.