Consider a bar which might have multiple openinghours, depending on the day of week (+ some special days when it might be closed)
I want to be able to lookup all bars that are currently open and that will be open for the next, say, 3 hours. (or be able to ask: 'open on 18-10-2011 from 7 until (at least) 10 )
The best thing I believe would be to have a 'open,close'-tuple for each date (other suggestions welcome)
Without, as far as I know ?, a fieldtype that combines open/close hours in 1 field, I can naively (but wrongly) define this structure using 2 fields: 'open' and 'closed', which need to be multivalued.
Now index them like:
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 queries would be of the form:
open < now && close > now+3h
But since there is no way to indicate that 'open' and 'close' are pairwise related I will get a lot of false positives, e.g the above document would be returned for:
open < 2011-11-09:0100 && close > 2011-11-09:0600
because SOME opendate is before 2011-11-09:0100
(i.e: 2011-11-08:1800
) and SOME closedate is after 2011-11-09:0600
(for example: 2011-11-11:0300
) but these open and close-dates are not pairwise related.
I have been thinking about a totally different approach using Solr dynamic fields, in which each and every opening and closing-date gets it's own dynamic field, e.g:
- _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
Then, the client should know the date to query, and thus the correct fields to query. This would solve the problem, since startdate/ enddate are nor pairwise -related, but I fear this can be a big issue from a performance standpoint (especially memory consumption of the Lucene fieldcache)
Thusfar, I haven't found a satisfactory solution. Any help highly appreciated.