thinking_sphinx嵌套日期搜索

时间:2012-07-13 04:31:51

标签: ruby-on-rails ruby ruby-on-rails-3 thinking-sphinx

假设我有以下情况:

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

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

修改

搜索需要为会议(即Conference.seacch)

1 个答案:

答案 0 :(得分: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