karmi/tire — Issue #208: Give a name to facet ranges
Author: niuage
Created: 2012-01-18 16:26:13+00:00
State: open

Hey,

In Sunspot, you can do the following:

bod = Time.zone.now.beginning_of_day
facet :start_time do
row :past do
with(:from).less_than bod - 1.day
end
row :today do
with :from, bod..(bod + 1.day)
end
row :week do
with :from, (bod)..(bod + 7.days)
end
#...
end

When I switched to elastic search, I replaced the above by:

facet("timeline") do
range :from, [
{ from: bod, to: bod+1.day }, #day
{ from: bod, to: bod+7.days }, #week
{ from: bod, to: bod+30.days }, #month
{ from: bod }, #upcoming
{ to: bod } #past
]
end

I was wondering if it was possible to give ranges some kind of identifiers, to make it easier when displaying the facets.
Also, if you know a better way to do it, dont hesitate.

Thanks