Hi Aisha

I'm not a PostgreSQL expect, so things are perhaps a little more flaky  
in TS when it comes to using that instead of MySQL. TS automatically  
pairs datetime columns (as they're defined in migrations) as timestamp  
attributes in Sphinx. If you're using a different database type (as  
determined by Rails), then the pairing is lost, and it defaults to  
integer, which is I assume what's happened for you.

I would like to fix this (as well as translate date columns to  
timestamps as well, and so on), but for the moment, your workaround is  
the best approach. Although you don't need the indexes call for  
effective_at - unless you want the timestamp to be matched by your  
search text? If you do, best to give it an alias so Sphinx doesn't get  
confused.

Cheers

-- 
Pat

On 09/12/2008, at 4:34 PM, [email protected] wrote:

>
> I've got an application using Thinking Sphinx 0.9.5. I'm want to order
> by the attribute 'created_at' but it isn't working. When I order by
> this when doing the search it seems to have no effect (but the search
> works otherwise).
>
> I have my index defined like this:
>
>  define_index do
>    indexes name
>    has created_at
>  end
>
> And search like this:
>
>    @events = Event.search(params[:search],
>                :match_mode => :extended,
>                :order => :created_at,
>                )
>
>
> When I've logged the output commi
>
> I've done a little bit of debugging and I noticed one thing
> suspicious. The sql_query built by TS puts the created_at column  in
> the select statement. Presumably Sphinx would select something out
> like "2008-12-07 02:21:38.050572". However TS defines the attributes
> as a "sql_attr_uint = created_at". Wouldn't this result in the string
> "2008-12-07 02:21:38.050572" being turned into an integer rather than
> the number of seconds since epoch?
>
> I've found this works around the problem.
>
>  define_index do
>    indexes name
>    indexes 'extract(epoch from effective_at)'
>    has 'extract(epoch from effective_at)', :as => :epoch, :type
> => :datetime
>  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
-~----------~----~----~----~------~----~------~--~---

Reply via email to