--
Murilo Soares Pereira
http://www.comp.ufscar.br/~murilo
I think I'll do that now.
On Dec 27, 5:22 pm, Murilo Soares Pereira <murilo.soar...@gmail.com>
wrote:
Although, are you wanting the text representations of dates to be searchable by users? Or do you want to filter on them? For the latter, attributes is what's needed, but otherwise, definitely go with fields, as you've already found.
--
Pat
> --
>
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
What I want is that the model that has the 'date' type field can be
ordered, example: Model.search("foo", :order => "date_field ASC").
--
Murilo Soares Pereira
http://www.comp.ufscar.br/~murilo
Then splitting the datetime over two attributes, as I described below, is the best approach... I think you'll need to create SQL snippets for your attributes, maybe something like the following (assuming MySQL):
has "CAST(DATE_FORMAT(datetime_col, '%Y%m%d') as UNSIGNED)", :type => :integer, :as => :datetime_date
has "CAST(DATE_FORMAT(datetime_col, '%H%i%s') as UNSIGNED)", :type => :integer, :as => :datetime_time
And then to get the ordering working nicely, the following should do the job:
Model.search('foo', :order => 'datetime_date ASC, datetime_time ASC')
This is all theory though - I've not tried it myself, but I think it'll work :)
--
Pat
I'm using PostgreSQL and tried the snippets you provided, but thinking
sphinx can't generate the config file. I'm googling to see if this SQL
statement is valid in PostgreSQL.
And I'm not using the 'time' attribute, only 'date'.
Cheers.
--
Murilo Soares Pereira
http://www.comp.ufscar.br/~murilo
has "CAST(TO_CHAR(date_field, 'YYYYMMDD') as INTEGER)", :type
=> :integer, :as => :date_field
group_by "date_field"
These two configurations are needed inside the 'define_index' block.
Hope it helps someone :)
Thank you Pat!