简体   繁体   中英

thinking_sphinx nested date search

Let's say I've got the following scenario:

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

I would like to search conferences based on the start time, so when I provide the start time it would return me the list of conferences which still have one or more meetings with start times after the provided time. Is this possible with thinking_sphinx? At the very least, how should I define my index?

EDIT

The search needs to be for Conferences (ie Conference.seacch)

class Meeting < ActiveRecord::Base
 belongs_to :conference

 ..
 define_index do
    indexes :start_time
    has conference_id
  end
end

Then

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM