lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avlesh Singh <avl...@gmail.com>
Subject Re: Searching for reservations/availability with Solr
Date Wed, 12 Aug 2009 11:18:26 GMT
>
> I'd have to add the year because things might end up reserved far ahead, or
> they might be reserved again on the same day next year.
>
If that is the case, then yes you'll have to take year into account too.

Wouldn't it be terribly inefficient when I have 10million+ documents in my
> index and i want to check all of em for availabilty over a 2 week period?
> That'd mean 14 extra parts in my query. I'm a bit worried that this might
> mess up efficiency a lot?
>
I don't see a reason as to why 14 Boolean clauses in a query should be
considered a problem. Actually, it is too small a number to worry about.
Moreover, you can use a negated range query, as Shalin proposed. You should
make the field of type sortable-int in that case.

Any way i could get the functionality you're describing without having to
> basically write my own data import handler implementation

Worst come worst, you may need to write a transformer.

Cheers
Avlesh

On Wed, Aug 12, 2009 at 4:38 PM, Constantijn Visinescu
<baelin82@gmail.com>wrote:

> Hi,
>
> This seems like a bit of an unconventional suggestion but it just might
> work.
>
> I'd have to add the year because things might end up reserved far ahead, or
> they might be reserved again on the same day next year.
> I do have 2 questions:
>
> 1) Wouldn't it be terribly inefficient when I have 10million+ documents in
> my index and i want to check all of em for availabilty over a 2 week
> period?
> That'd mean 14 extra parts in my query. I'm a bit worried that this might
> mess up efficiency a lot? (Yes, I have aprox 10 mil documents in my index
> ;))
>
> 2) I populate my index with a data import handler (
> http://wiki.apache.org/solr/DataImportHandler ) from a table that has
> lines
> that contain a foreign key to the room number, a reserved_from date and a
> reserved_to date. Any way i could get the functionality you're describing
> without having to basically write my own data import handler
> implementation?
>
> Constantijn Visinescu
>
> On Wed, Aug 12, 2009 at 10:49 AM, Avlesh Singh <avlesh@gmail.com> wrote:
>
> > >
> > > 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 <avlesh@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 <
> > baelin82@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
> > >>
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message