Or have two fields, dayofyear and dayofleapyear, then use the
right field in the right year. --wunder

On 4/7/09 4:32 PM, "Stephen Weiss" <swe...@stylesight.com> wrote:

> If someone's birthday falls on a leap year, in most countries their
> birthday is considered to be February 28th unless it happens to be a
> leap year.  You could make the field a float, encode the day number as
> 59.5, so it will match where it should, and write special handling
> along these lines:
> 
> <?php
> $year = (int) strftime("%Y");
> $date_text = ($day == 59.5 && $year % 4 == 0 && $year % 100 > 0) ?
> "February 29" : strftime("%B %e", (strtotime("January 1, $year") +
> ((floor($day) - 1) * 86400)));
> ?>
> 
> Sorry, I love this kind of thing.
> 
> --
> Steve
> 
> On Apr 7, 2009, at 6:00 PM, Chris Hostetter wrote:
> 
>> 
>> : Hi everyone,
>> :      I have an index that stores birth-dates, and I would like to
>> search for
>> : anybody whose birth-date is within X days of a certain month/day.
>> For
>> : example, I'd like to know if anybody's birthday is coming up
>> within a
>> : certain number of days, regardless of what year they were born.
>> How would I
>> : do this using Solr?
>> 
>> You've already indexed the data as a DateField? ... hmmm .... i can't
>> think of any way to do that type of query without writing a custom
>> plugin
>> that can iterate over all the terms in the index.
>> 
>> :      As a follow-up, assuming this query is executed very often,
>> should I
>> : maybe be indexing something other than the birth-date? Such as
>> just the
>> : month-day pair? What is the most efficient way to do such a query?
>> 
>> if you aren't too picky about leap years, the simplest appraoch would
>> probably be to just index the day of the year they were born on as an
>> integery ... your query code will have to be a little smart about
>> moduloing arround the start/end of the year.
>> 
>> if you are picky about leap years .... hmmm .... i've got nothing.
>> 
>> 
>> -Hoss
>> 
> 

Reply via email to