On Tue, Aug 11, 2009 at 6:13 PM, Shalin Shekhar Mangar < shalinman...@gmail.com> wrote:
> On Tue, Aug 11, 2009 at 7:08 PM, Constantijn Visinescu > <baeli...@gmail.com>wrote: > > > > > <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 not sure how you are creating the dynamic field's name. But if you know > the field name, the query can be like this: > > q=*:*&fq=-reserved_from:[2008-08-15T00:00:00Z TO 2008-08-18T00:00:00Z] > > Note the minus at the start of the fq. The above query says give me all > documents (q=*:*) excluding the ones in which reserved_from is between 15th > to 18th August. > > -- > Regards, > Shalin Shekhar Mangar. It wolud be ideal if i can get this working, but the above query includes room 1, which is reserved for all of august, in the search results when i want all the rooms that are avaliable from aug 15th, to aug 18th. The above query would be ideal if i can get it working, I'm just not sure how :) i've done some experimenting but i can't seem to get the query quite right