First off - sorting on a string value seems to be “unsupported”, at least based on the message you get when you add one to your ranking formula:
Attribute with String Values
title contains string values. The ranking formula expects numerical or boolean values.
This seems nuts, especially for a searching/indexing tool like Algolia. You would be forcing everyone to index a “alpha sort numerical value”.
Luckily, if you ignore the notice, it seems to handle sorting string attributes just fine (at first).
At the very least I think there needs to be some clarification as to if this is supported or not. Your support staff seems to recommend its use, despite the warning message: Sort is not working - Open Q&A - Algolia Community, Sorting Alphabetically on the sample index
What I’m after is an index that is sorted alphabetically by an attribute.
There will be a text search as well, so I want the results sorted by this attribute first (“sort-by attribute”) followed by the default textual matching.
The initial sort on a string attribute works. The problems occur when the are combined with a text search:
I’ve found that it seems the default textual ranking criteria , despite being below my sort-by attribute in the ranking formula, seems to throw the rank off.
Here’s an example, with the above ranking settings. You’ll notice it starts sorted, but search for “hello”, and you’ll see the rank distort: JSFiddle
Furthermore, I’ve found if I remove the defaults all together, the sorting works as expected, even with a text search.
Example: (search for “hello” again) JSFiddle
It seems like the default textual rankings weight heavier than a sort-by attribute, even if the sort-by is higher in the ranking formula.
Furthermore, I feel like you should document and support alpha sorting, since it “works”, is a pretty basic need, and is already being recommended by support. Fixing the above issues with ranking and removing the warning when you add a string sort-by would be a good start.