0

假设我有以下情况:

class Conference < ActiveRecord::Base
    has_many :meetings

    define_index do
        # index
    end
end

class Meeting < ActiveRecord::Base
    belongs_to :conference

    validates_presence_of :start_time
    validates_presence_of :end_time
end

我想根据开始时间搜索会议,所以当我提供开始时间时,它会返回给我的会议列表,这些会议在提供的时间之后仍然有一个或多个会议的开始时间。这可能与thinking_sphinx?至少,我应该如何定义我的索引?

编辑

搜索需要针对会议(即 Conference.sacch)

4

1 回答 1

1
class Meeting < ActiveRecord::Base
 belongs_to :conference

 ..
 define_index do
    indexes :start_time
    has conference_id
  end
end

然后

Meeting.search :conditions => {:created_at => 1.week.ago..Time.now}

http://freelancing-god.github.com/ts/en/indexing.html

http://freelancing-god.github.com/ts/en/searching.html

于 2012-07-13T04:45:35.807 回答