Mark L
Mark L

Reputation: 13435

Sorting on full text columns in sphinx

I know you can sort by integer values in sphinx but is there a way I can get sphinx to sort by a text field alphabetically?

I want to search on first name and instead of sorting on relevance, I'd like to sort by the first name alphabetically. I know I can do this in mysql but in mysql I don't have features like stemming (as far as I know).

Thanks Everyone!

Upvotes: 0

Views: 2643

Answers (3)

Moosh
Moosh

Reputation: 396

ordinal attribute is the easiet solution if you use a monolitic index. If you use a distributed index you have a problem. but there is other solutions.

1° convert your string in numeric value. from sql with something like conv(HEX(textfield),16,10)

hex is friendly with string and return a concatened list of hexa values of chars)

2° with sphinx 2.0-x try sql_string_field

Upvotes: 2

pat
pat

Reputation: 16226

You can use strings as ordinal attributes - Sphinx will collect all values of the given column, sort them alphabetically, then give the first one a value of 1, the second a value of 2, and so forth. This allows for sorting, but not filtering.

Upvotes: 2

Ty W
Ty W

Reputation: 6814

As far as I know you can't sort by anything other than attributes (and a few special attributes like @weight, etc.). Currently attributes cannot be strings, but this feature should be coming in 0.9.10 from what he's said about it.

http://www.sphinxsearch.com/docs/current.html#sorting-modes

Upvotes: 1

Related Questions