Sphinx handles sorting by string fields, storing all the values in a list, sorting the list, and then storing the index of each row as an int attribute. According to the docs, this list is sorted at the byte level and is not currently configured.
Ideally, strings should be sorted differently, depending on the encoding and locale. For example, if the strings are known to be Russian text encoded in KOI8R, sorting bytes 0xE0, 0xE1 and 0xE2 should result in 0xE1, 0xE2 and 0xE0, because in the value KOI8R 0xE0 encodes a character that is (noticeably) after the characters encoded by 0xE1 and 0xE2. Unfortunately, Sphinx does not currently support this and simply sorts the lines in turn.
- from http://www.sphinxsearch.com/docs/current.html
So, there is no easy way to achieve this in Sphinx. Modifying your idea of REPLACE () would be to have a separate column and populate it with a callback in your model. This will allow you to handle the replacement in Ruby instead of MySQL, perhaps a more suitable solution.
source share