Hi Joan

You will want to use :with for the date range - and then you'll need wildcards 
for the city matching. You can find the relevant settings here:
http://freelancing-god.github.com/ts/en/common_issues.html#wildcards

And so your query will become:

  Client.search params[:generic_text],
    :conditions => {:city => "*#{params[:city]*"},
    :with => {:created_at => params[:start_date]..params[:end_date]}

Although you'll want to make sure params[:start_date] and params[:end_date] are 
actually Time objects.

Cheers

-- 
Pat

On 11/11/2011, at 12:14 PM, Joan Ruiz wrote:

> Hello
> 
> I have a search form with 4 text fields: generic text, city, start
> date and end date. Generic text uses TS to search on name, registered
> name and contact's name and I need a query like this:
> 
> Client.search("params[:generic_text]", :conditions => ["city like ?
> and created_at > ? and created_at < ?", "%params[:city]%",
> params[:start_date], params[:end_date]])
> 
> I have seen that I can use :with to search on the range of dates, but
> I can't find something similar to "city like ?"
> Am I missing something? Any help would be really appreciated
> 
> These are my indexes on the Client model
> 
> define_index do
>    indexes :name
>    indexes registered_name
>    indexes contacts.name, :as => :contact
>    has :country
>    has :created_at
> end
> 
> pd: sorry for the bad English
> 
> -- 
> 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