Hi Stefan
I think you should just be able to put that complex logic into an attribute,
and use that for sorting:
has "if( user_score ... )", :as => :custom_score, :type => :integer
And then in searching, assuming you've got qualified as an attribute, and
:sortable on user_name (or an explicit attribute based on that column):
Model.search 'foo',
:order => 'qualified DESC, custom_score ASC, user_name ASC'
Let us know if that doesn't work.
Cheers
--
Pat
On 10/12/2010, at 1:58 AM, Stefan wrote:
> Hello everyone!
>
> I am trying to "translate" a mysql query to sphinx. The complicated
> part is the ORDER BY clause. It is as follows:
>
> ORDER BY qualified DESC,
> if( user_score, if(( user_score=0 AND (user_title_en!=''
> OR user_title!='')),-1,0),0),
> if( user_pref, if( user_privilegies=0 , -1, 0), 0),
> if( qualified, to_days(exam_date), -
> (to_days(signup_date))),
> user_name
>
> Please, could anyone tell me if it is possible to sort results like
> this in sphinx. I am searching for answers almost a week now and the
> only think I found is information about "SPH_SORT_EXPR mode". But I
> can't understand exactly how it works so I can chain all the "IF"
> statements.
>
> 10x in advance!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.