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

開始時刻に基づいて会議を検索したいので、開始時刻を指定すると、開始時刻が指定された時刻より後の会議が 1 つ以上ある会議のリストが返されます。これは、thinking_sphinx で可能ですか? 少なくとも、インデックスをどのように定義すればよいですか?

編集

会議を検索する必要があります (つまり、Conference.seacch)。

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 に答える