Hi Ian

What Jim's suggested is exactly much what you need: the date column 
(created_at, in this case) must be an attribute:

  define_index do
    # ...
    has created_at
  end

And then you can filter on a range of times to get any records within that 
range (note the :with argument):

  Job.search params[:search],
    :sort_mode => :extended,
    :page      => params[:page],
    :order     => 'job_number_sort DESC',
    :with      => {:created_at => from_time..to_time}

Don't forget to run 'rake ts:rebuild' to reindex and restart Sphinx after 
adding the attribute, to ensure the data is there for the filter to work.

Cheers

-- 
Pat

On 17/07/2010, at 3:32 AM, Chiyu Ian He wrote:

> Let me elaborate on my situation:
> 
> Currently, I have a working search engine but I am trying to make an
> advanced search engine that does more complex operations. One of those
> tasks is to allow the user to select a date range (created_at) and
> pull up all the jobs from that range.
> 
> This is my model:
> 
> define_index do
>   indexes client_name
>   indexes analyst
>   indexes client_job_number
>   indexes due_date
>   indexes report_date
>   indexes job_number
>   has job_number, :as => :job_number_sort
> 
>   set_property :delta => true
> 
> end
> 
> This is my controller:
> 
> def index
>    @page_title = 'Jobs List'
>    @jobs = Job.search params[:search], :sort_mode
> => :extended, :order => "id DESC", :page => params[:page], :per_page
> => 20, :order => "job_number_sort DESC"
>  end
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to