Search code examples
sphinxthinking-sphinx

ThinkingSphinx3: Just upgraded from TS2 & getting odd sort_by error message


I have the following attribute in my Ad model:

has sort_by_date, :as => :timestamp, :sortable => true

In the ads table there is a sort_by_date field, which is a datetime field.

However when I search, passing the following as my :order option (I want to show newer ads first & then sort by relevance)

:order => "sort_by_date DESC, @weight DESC"

I am getting the following error:

ThinkingSphinx::SphinxError (index ad_core: sort-by attribute 'sort_by_date' not found):

Can anyone see why this might be happening?

Thanks!


Solution

  • Ok, so I got this working by changing my sort_by_date field in the database from a datetime to a timestamp, hope this helps someone else out.