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:
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.
While keeping granularity on Bars like I want (instead of BarsxDate) it's possible to use the expirimental Lucene Spatial Playground implementation.
The use-case + general solution is here: https://issues.apache.org/jira/browse/SOLR-2155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=comment-13115244#comment-13115244
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With