Consider a panel that can have several openings, depending on the day of the week (+ some special days when it can be closed)
I want to be able to look for all the bars that are currently open and which will be open for the next, say, 3 hours. (or be able to ask: "open 18-10-2011 from 7 to (at least) 10)
The best I believe would be to have an "open, closed" tuple for each date (other suggestions welcome)
Without, as far as I know ?, the type of field that combines the opening / closing time in 1 field, I can naively (but mistakenly) define this structure using 2 fields: "open" and "closed", which should be multi-valued.
Now index them like this:
open: 2011-11-08:1800 - close: 2011-11-09:0300
open: 2011-11-09:1700 - close: 2011-11-10:0500
open: 2011-11-10:1700 - close: 2011-11-11:0300
And the queries will look like:
open < now && close > now+3h
But since there is no way to indicate that "open" and "close" are associated with a pair, I get a lot of false positives, for example, the above document will be returned for:
open < 2011-11-09:0100 && close > 2011-11-09:0600
because SOME opendate before 2011-11-09:0100(ie:) 2011-11-08:1800and SOME closed after 2011-11-09:0600(for example:) 2011-11-11:0300, but these open and closed dates are not pairwise related.
I was thinking of a completely different approach, using Solr dynamic fields, in which each opening and closing date gets its own dynamic field, for example:
- _date_2011-11-09_open: 1800
- _date_2011-11-09_close: 0300
- _date_2011-11-09_open: 1700
- _date_2011-11-10_close: 0500
- _date_2011-11-10_open: 1700
- _date_2011-11-11_close: 0300
, , . , startdate/enddate , , ( Lucene)
, .
.