> Hi,
> 
> I'm new to Solr but so far I think its great.  I've
> spent 2 weeks reading
> through the wiki and mailing list info.
> 
> I have a use case and I'm not sure what the best way is to
> implement it.  I
> am keeping track of peoples calendar schedules in a really
> simple way: each
> user can login and input a number of date ranges where they
> are available
> (so for example - User Alice might be available between
> 1-Jan-2010 -
> 15-Jan-2010 and 20-Feb-2010 - 22-Feb-2010 and
> 1-Mar-2010-5-Mar-2010.
> 
> In my data model I have this modelled as a one-to-many with
> a User table
> (consisting of username, some metadata) and an Availability
> table
> (consisting of start date and end date).
> 
> Now I need to search which users are available between a
> given date range. 
> The bit I'm having trouble with is how to store multiple
> start & end date
> pairs.  Can someone provide some guidance?


Many discussions have been made about solr data normalization.
You need to flatten you data. There will be repeated data.

In your case this can be an example:

fields:
id
user
end_date
start_date

id=0 user=Alice start_date:1-Jan-2010  end_date:15-Jan-2010 
id=1 user=Alice start_date:20-Feb-2010 end_date:22-Feb-2010
id=2 user=Alice start_date:1-Mar-2010  end_date:5-Mar-2010.


your query can be = start_date:[* TO given_start_date] AND 
end_date:[given_end_date TO *]

If you want Exclusive range query you can use { } curly brackets.

If you think that one user has overlapping available dates, you can facet on 
user field. &facet=true&facet.field=user&facet.mincount=1 This will give you 
distinct users.

If you are stroing your data in database, you can use 
http://wiki.apache.org/solr/DataImportHandler to index you data.

hope this helps.



Reply via email to