> > Searches would be for documents (rooms) that don't have certain dates in > their multi-valued fields for the a particular month. > E.g if you wanted to find out rooms available on 15th, 16th and 17th of > August, the query could be: > q=!(+reserved_dates_August:15 +reserved_dates_August:16 > +reserved_dates_August:17) >
I was too fast to suggest the query above. The dates should be individually negated. Cheers Avlesh On Tue, Aug 11, 2009 at 9:39 PM, Avlesh Singh <avl...@gmail.com> wrote: > From what I understood, you need a day level granularity (i.e booked on > 15th, 16th and 17th of August) in your indexes. If this is true, then why > even store a "date"? For your use case, I think this should suffice - > <dynamicField name="reserved_dates_*" type="integer" indexed="true" > stored="true" multiValued="true"/> > > Each document will have values like these for this particular field - > reserved_dates_August => 15, 16, 19 > reserved_dates_September => 1, 3 > .... > > Searches would be for documents (rooms) that don't have certain dates in > their multi-valued fields for the a particular month. > E.g if you wanted to find out rooms available on 15th, 16th and 17th of > August, the query could be: > q=!(+reserved_dates_August:15 +reserved_dates_August:16 > +reserved_dates_August:17) > > Hope this helps. > > Cheers > Avlesh > > > On Tue, Aug 11, 2009 at 7:08 PM, Constantijn Visinescu <baeli...@gmail.com > > wrote: > >> Hello, >> >> I have a problem i'm trying to solve where i want to check if objects are >> reserved or not. (by reservation i mean like making a reservation at a >> hotel, because you would like to stay there on certain dates). >> >> I have the following in my schema.xml >> >> <field name="name" type="text" indexed="true" stored="true"/> >> <dynamicField name="reserved_from_*" type="date" indexed="true" >> stored="true"/> >> <dynamicField name="reserved_to_*" type="date" indexed="true" >> stored="true"/> >> >> and the follwoing 2 documents in Solr >> >> <doc> >> <str name="name">Room1</str> >> <date name="reserved_from_11">2000-08-01T00:00:00Z</date> >> <date name="reserved_to_11">2000-08-31T23:59:59Z</date> >> </doc> >> <doc> >> <str name="name">Room2</str> >> <date name="reserved_from_24">2000-08-01T00:00:00Z</date> >> <date name="reserved_to_24">2000-08-13T23:59:59Z</date> >> <date name="reserved_from_36">2000-08-20T00:00:00Z</date> >> <date name="reserved_to_36">2000-08-22T23:59:59Z</date> >> </doc> >> >> Now i want to run a query that gives me all documents(rooms) that are >> avaiable from aug 15th to aug 18th (should return Room2), or from aug 10th >> to aug 15th (should return none) or from sept 1st to sept 5th (should >> return >> both). >> >> Is it possible to run queries like this in solr? (either with my current >> schema setup, or a different one that accomplishes the same idea). >> >> I'm at a loss as to how to formulate a solr query to get the data i want. >> >> Thanks in advance, >> Constantijn Visinescu >> > >