On 05/08/2009, at 12:05 PM, Thibaut Barrère wrote:

> I'm looking to add facets that are based on today's date, ie:
>
> - less than one month old [30]
> - less than one year old [74] (or between 1 and 12 months maybe so
> that these are exclusive)
> - more than one year old [100]
>
> It's obviously all based on which day we are today.
>
> So I've got one solution which would be to reindex each night (my
> content is low-volume enough so that it's tolerable).
>
> Is there a nicer way to achieve this ?

Well, I'm not sure about nicer, but you could use ThinkingSphinx.count/ 
Model.search_count with filters on the created_at attribute to get  
each of those values. It's not facets, but it'll do the same job.

> As well, did anyone implement some dive-in date facets ? (first years,
> 2009, 2008, 2007, then if the user selects 2009 displays months inside
> instead, etc..) ?

Hmm, this is trickier... you could create a facet on the year, and a  
facet on the month, and only request the year facet for the upper  
level, then only request the month facet (while filtering on year) for  
the lower level.

has 'YEAR(created_at)',  :as => :year,  :type => :integer, :facet =>  
true
has 'MONTH(created_at)', :as => :month, :type => :integer, :facet =>  
true

Model.facets :facets => [:year]
Model.facets :facets => [:month], :with => {:year => 2008}

-- 
Pat
--~--~---------~--~----~------------~-------~--~----~
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