Reputation: 2567
Helo, I am new in Sphinx search. I want to get all rows ordered by first_name, but does not happend. Here is my source file:
return
"source instructorSourse: _CONNECT_NAME_
{
sql_range_step = 1000
sql_query = SELECT id, first_name, last_name, country_id, city_id, is_banned, is_deleted, is_confirmed, dive_level as dive_level, UNIX_TIMESTAMP(last_activity) AS last_activity \
FROM user AS u \
WHERE dive_level = 'instructor' \
ORDER BY first_name DESC
sql_attr_bigint = country_id
sql_attr_bigint = city_id
sql_attr_bool = is_banned
sql_attr_bool = is_deleted
sql_attr_bool = is_confirmed
sql_attr_timestamp = last_activity
}";
But it still return rows without order. What I am doing wrong?
Upvotes: 0
Views: 73
Reputation: 21091
sql_query
is just getting the data to indexer, it doesnt matter what order you use, indexer will reorder stuff to build the index.
To be able to order the results you need to make sure the column is stored in the index - as an attribute. (in your example you could order results by last_activity
as its an attribute)
So you need to make last_name
at attribute, sql_attr_string
might be useful, but maybe sql_field_string
even better, as it makes BOTH a string
and attribute
.
Upvotes: 1