名と姓の組み合わせでクエリの結果を並べ替えたい。
ユーザーモデルには次のように定義されたインデックスがあります
define_index do
indexes :first_name
indexes :last_name
has first_name, :as => :fname
has last_name, :as => :lname
end
私のコントローラーのアクションでは、このような結果を取得しています。
@results = User.search(query,
:with => options,
:order => "fname ASC",
:match_mode => :extended).page(params[:page]).per(11)
結果を first_name で並べ替えると、結果は次のようになります。
Micheal Clark
Niel Johnson
Micheal Beaven
しかし、first_name と last name の組み合わせで結果を並べ替えたいと思います。このようなものを返す必要があります。
Micheal Beaven
Micheal Clark
Niel Johnson