lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geert-Jan Brits <>
Subject Re: Opening hours search
Date Mon, 26 Sep 2011 20:51:01 GMT
Hi Jan,

Thanks, you're probably right this question sits better in dev.

I didn't know of Poly Fieldtypes, sounds interesting.
Ideally I want to have a multivalued Poly FieldType: "openinghours", which
contains tuples of <DateTime,DateTime> representing <openingdateTime,
but from a pretty recent comment from Grant Ingersoll in
doesn't seem to be supported.

I believe this means that your suggestion of representing the data as
follows, would not give good reliable results either, since the field
'open-tu' is multivalued?

> <field name="open-mo">0900,1600</field>
> <field name="open-tu">0800,1200</field>
> <field name="open-tu">1400,1900</field>
> <field name="open-we">0900,1600</field>

Moreover, I like to represent openinghours on the more detailed Date-level,
because otherwise I can't incorporate special openinghours on special dates
like national festivities, etc. which may be different from the usual

Forgetting the multivalued-roadblock for a second, it seems from
rangequeries on Poly FieldTypes seem to work differently than what I need.
For sake of argument lets say a multivalued field 'openinghours' exists.
Then I need to do range-queries of the form like you suggest,  (values are
not real datetimes, but you get the point):

openinghours[open TO close], e.g:
openinghours:[20110822:2200 TO 20110823:0400]

But instead it 'only' seems possible to use range-queries, like:
openinghours[openA,closeA TO openB,closeB], which is not what I need,

hmm just thinking about this, would this work? :
openinghours[20110822:2200,* TO *,20110823:0400]

Trying to wrap my head on this one.
 - In short, Poly FieldTypes seems to get close, but the combi Poly
FieldTypes and multivalued isn't implemented afaik. Any patches in the
making on this?  Would it be trivial?
 - would querying work (forgetting the multivalued problem for a moment)

Back to Solr2155 and  Lucene Spatial Playground for a second.
Here multivalued (lat/long)points are implemented. So this means a special
case of multivalued Poly FieldTypes is implemented.
Which would mean that the following would work IFF the querying part works:

openinghours[latitude,* TO *,longitude]
where 'latitude' is open encoded as latitude, and close is encoded as

Sorry for the rambling / braindump style post.
I do appreciate some pointers if I'm barking up the right tree or not


Op 26 september 2011 21:52 schreef Jan Høydahl <> het

> Hi Geert-Jan

I think this discussion is better suited in dev-list than in an issue
> regarding Geo-spatial, so I'm continuing the discussion in this new thread.
> Geospatial LatLonType is implemented as a PolyField
> Another example is MoneyFieldType in SOLR-2202, indexing both a amount
> value and currency type together.
> You could probably use Poly Fields for opening hours pairs as well. Imagine
> a TimeRangeFieldType which holds a from-to value between 00:00 and 23:59.
> And then feed a document with from-to pairs:
>  <field name="open-mo">0900,1600</field>
>  <field name="open-tu">0800,1200</field>
>  <field name="open-tu">1400,1900</field>
>  <field name="open-we">0900,1600</field>
> …
> Have no practical experience in programming FieldTypes but I imagine it
> could be done this way, and then be able to query for e.g. open-tu:[1500 TO
> 1800] to find shops open on tuesday from 1500 and three hours..
> --
> Jan Høydahl, search solution architect
> Cominvent AS -
> Solr Training -
> > David,
> >
> > I try not to swamp this discussion, but I have a totally different issue
> for which I might misuse this patch / LSP.
> >
> > It's about pois having multiple openinghours (depending on day of week,
> special festivitydays, and sometimes even multiple timeslots per day)
> > I want to query, for example, all pois that are open NOW, and that will
> remain open until NOW+3H.
> >
> > For background see:
why all normal approaches don't work (afaik): basically it's about
> needing multiple opening/closing times and having them be pairwise related.
> >
> > I have the feeling that opening/closing datetimes might be modelled as
> multiple lat/long points. But I would need a query of the form:
> >
> > Given a user defined point x, return all docs that have a point p defined
> for which:
> > - x.latitude > p.latitude
> > - x.longitude < p.longitude
> >
> > Is this possible? (As far as I see GeoFilt, BBox, GeoDist don't provide
> me with what I need)
> >
> > Basically this is how I envision encoding it:
> > - each <open,closedelta)>-tuple is represented as a (lat/long)point
> > - open is matched on latitude
> > - closedelta (closedelta is represented as delta from open) is matched on
> longitude
> > - granularity is 5 minutes
> >    - open can be a max of 100 days in future -> ~30.000 distinct values.
> >    - closedelta can be at most 24 hours -> ~300 distinct values
> >
> > The above lat/long query applied to the domain would become:
> > Given a user defined open/closedelta-datetime x, return all docs that
> have a open/close-datetime p defined for which:
> > - > (poi is already open at requested opening time)
> > - x.closedelta  < p.closedelta (poi is not yet closed on the requested
> closing time)
> >
> > In other words, the poi is open from the requested open-datetime until at
> least the requested close-datetime.
> >
> > Ok, good exercise in writing this down, the question remains is this
> query possible (perhaps with some coding-efforts)?
> >
> > Thanks,
> > Geert-Jan
> >
> >

View raw message