思考狮身人面像 - 跨多个模型排序

时间:2012-11-20 14:32:45

标签: ruby-on-rails thinking-sphinx

要显示目录,我正在搜索各种模型中的大量项目,这些项目都以这样的特定字母开头

@everything = ThinkingSphinx.search(
               "@name ^?",
               @letter,
              :match_mode => :extended,
              :classes => [Performer, Promoter, Tour, Venue, User],
              :order => :name_sort,
              :sort_mode => :asc
              )

但是项目不按字母顺序排序。如果我将asc更改为desc,则顺序会发生变化,但仍然没有可辨别的模式。

索引设置如下

performer.rb
define_index do
  indexes name, :sortable => true
  indexes description
  has created_at, updated_at
end


promoter.rb
define_index do
  indexes name, :sortable => true
  indexes description
  has created_at, updated_at
end


tour.rb
define_index do
  indexes name, :sortable => true
  indexes description
  has created_at, updated_at
end

venue.rb
define_index do
  indexes name, :sortable => true
  indexes description
  has created_at, updated_at
end

user.rb
define_index do
  indexes first_name, :sortable => true
  indexes last_name, :as => :name, :sortable => true
  indexes bio
  has role, created_at, updated_at
end

正如你所看到的那样,用户索引别名last_name作为名称,但这是唯一的奇怪之处。

我正在使用思考sphinx 2.0.12

0 个答案:

没有答案